美文网首页
Spring Boot 总结一些问题

Spring Boot 总结一些问题

作者: 光小月 | 来源:发表于2019-08-09 14:36 被阅读0次

1.如何在 Spring Boot 启动的时候运行一些特定的代码?
可以实现 CommandLineRunner或者ApplicationRunner 接口,重写Run方法,这样可以运行一些配置信息,或者加载一些es链接信息

2 . 如何让项目不继承spring-boot-starter-parent?
pom.xml中编写

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <version>1.5.1.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

默认的是

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.1.RELEASE</version>
</parent>
  1. Spring 中注解的原理
    注解只是起到配置的作用,没有其他用处,实现原理就是利用java的反射原理

相关文章

网友评论

      本文标题:Spring Boot 总结一些问题

      本文链接:https://www.haomeiwen.com/subject/pclgwqtx.html