Maven configuration with Spring Boot & multi modules - run application in Intellij

前端 未结 3 1358
闹比i
闹比i 2020-12-08 16:09

I\'m currently working on a REST API with Spring Boot.

I\'m new to Maven and have just started coding with IDEA (don\'t know well this IDE yet), and I have a problem

3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-08 16:35

    also note that in case of JPA Entities and repositories are not in sub packages of Application.java's package then @Entityscan and @EnableJpaRepositories MUST be declared in the Application class, e.g:

    @Configuration
    @ComponentScan(basePackages="com.my.pack")
    @EnableAutoConfiguration
    @EnableJpaRepositories(basePackages="com.my.pack")
    @EntityScan(basePackages="com.my.pack")
    public class Application{
    
        public static void main(String[] args) {
            SpringApplication.run(Application.class, args);
        }
    }
    

提交回复
热议问题