java - Using different packages for Controllers when using Spring -


If I create a standard spring project in Spring Toolkit, then it works great!

I go to the local host: 8080 / greeting and get my Hello world feedback.

If I copy those 2 files into another source in my source tree and then go to the local host: 8080 / I receive an email:

  Whitelabel Error page There is no clear mapping for this application / error, so you are seeing it as a fallback. Fri 17 October 18:15:45 BST 2014 was an unexpected error (type = not found, position = 404).  

Transferring 3 sections in the same basic package solves the problem but from the point of view of a source tree organization it is not what I have to do.

Some may be due to automatic configuration, please someone can tell me what to do to give my project support in the form of controllers and objects as many packages.

If your code appears in the tutorial, then servlet-reference.xx Open and

  & lt; Reference: component-scan support package = "..." />  

You can list multiple packages. Use commas as separators.

Update:

This was for XML-based configurations.

If you create a "Spring Boot app", then the configuration is annotated-based. In this case, you have to search the sections encoded with @ComponentScan . Usually this is a main square or class called AppConfig.

By default it searches for frequent controllers and other components starting with the class' package. You can add the parameters of this annotation like this:

  @ComponentScan ({"xyzservices", "xyzcontrollers"})  

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

c# - NewtonSoft JArray - how to select multiple elements with LINQ -

javascript - amcharts makechart not working -