Jar包里面的JpaRepository无法被扫描
- @ComponentScan(basePackages = “xxx.xxx.xxx”):扫描 @Controller、@Service 注解;
- @EnableJpaRepositories(basePackages = “xxx.xxx.xxx”):扫描 @Repository 注解;
- @EntityScan(basePackages =“xxx.xxx.xxx”):扫描 @Entity 注解;
Spring Boot 使用外部中间件运行
- 引入jar包
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
2.改写spring boot的启动函数,如下
public class SeerApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(SeerApplication.class);
}
public static void main(String[] args) {
SpringApplication.run(SeerApplication.class, args);
}
}
PS:本人使用Spring Boot 2.0.5,其中用到lombok(默认为1.16.22),其中tomcat的版本要高于8.5.34