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>
- Spring 中注解的原理
注解只是起到配置的作用,没有其他用处,实现原理就是利用java的反射原理
网友评论