Configuration using annotation @SpringBootApplication

前端 未结 5 1841
挽巷
挽巷 2020-11-27 18:15

I have problem with Spring Boot configuration.

I have created base Spring Boot project using https://start.spring.io/

And I have a problem, configuration wor

5条回答
  •  半阙折子戏
    2020-11-27 19:13

    I was having the same problem and to solve it I renamed my packages like this.

    "com.project"

    there you can place your SpringBootAplication main class, then just create the others packages beginning with "com.project"

    "com.project.dao"

    "com.project.controller"

    Creating this sub project structure you have no need to use scanBasePackages in @SpringBootApplication annotation, doing this your main class will be able to find every component in your project.

    And in case you chose to use scanBasePackages remember that you need to set all your components packages like this.

    @SpringBootApplication(scanBasePackages = {"com.project.dao", "com.project.controller"})

提交回复
热议问题