If I create a standard Spring project in the spring toolkit it works great!
I visit localhost:8080/greeting
and get my hello world
response.
If I copy those 2 files into another package in my source tree and then visit localhost:8080/greeting
I get a :
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback. Fri Oct 17 18:15:45 BST 2014 There was an unexpected error (type=Not Found, status=404).
Moving the 3 classes into the same default package fixes the problem but from a source tree organization perspective, this is not what I want to do.
I expect this to be due to some auto-configuration so please can somebody tell me what I have to do to allow my project to support multiple packages as controllers and objects.
Assuming the main method is in the package called com.setech.app and a controller is in a package called com.setech.controller.
For spring-boot 1.3.x upwards try this by adding "scanBasePackages" like this.
@SpringBootApplication(scanBasePackages = { "com.setech"} )
public class ResttanslatorApplication {
public static void main(String[] args) {
SpringApplication.run(ResttanslatorApplication.class, args);
}
}
Credit goes to Kamil Wozniak from here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With