I have two Spring Boot in a Maven project in Eclipse. Lets call it project1 and project2. I have to use some POJO classes in project1 from project2. So I made project2 a dependency of project1. If I use project1 in eclipse it works fine. However if I create a war file from project1 I get an exception during startup in Tomcat.
Could not autowire field: private com.project2.entity.SomeBean com.project2.controller.SomeController.someBean;
So it seems Spring try to autowire the fields in project2 while I only want to use some POJO from project2. Do you have any idea how to prevent it?
This is my project1 application. As you can see I tried ComponentScan's exlude filter without success. I guess it works differently when I use it from Tomcat.
@SpringBootApplication
@ComponentScan(basePackages = {"com.project1"} ,excludeFilters = @ComponentScan.Filter(type = FilterType.ASPECTJ, pattern = "com.project2.*"))
public class Project1Application extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(AbstractServiceGuiApplication.class);
}
public static void main(String[] args) {
SpringApplication.run(AbstractServiceGuiApplication.class, args);
}
}