Reputation: 35
I have 2 maven packages, both of them with spring boot dependencies. CoreApplication and CustomerApplication. Both apps have Spring MVC controllers, views and static resources.
In CoreApplication I dont have any runner class annotated with @SpringBootApplication.
In CustomerApplication pom.xml I use CoreApplication as a dependency.
If I run the CustomerApplication @SpringBootApplication annotated runner class, it finds the controllers in CoreApplication, but not the views. It can serve requests like http://localhost:8080/core/index, but I get an error from thymeleaf. (org.thymeleaf.exceptions.TemplateInputException: Error resolving template "index")
Is it possible what I want to do? How can I have a Core module with all common app specific stuff and a Customer app for every customer with their own business logic?
Upvotes: 0
Views: 810
Reputation: 517
Maybe you can try:
Annotate your CoreApplication
module with @SpringBootApplication
to let Spring manage and initialize your app as usual:
@SpringBootApplication
public class CoreApplication {
public static void main(String[] args) {
SpringApplication.run(CoreApplication.class, args);
}
}
And in your CustomerApplication
's runner, you can put:
@SpringBootApplication
public class CustomerApplication {
public static void main(String[] args) {
new SpringApplicationBuilder()
.sources(CoreApplication.class, CustomerApplication.class)
.run(args);
}
}
This way Spring will initialize your two modules properly.
Upvotes: 1