spring boot包扫描不到controller层
启动类代码
package com.maven.demo;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@SpringBootApplication
@EnableAutoConfiguration
@ComponentScan("com.maven.demo")
@MapperScan("com.maven.demo")
@EnableTransactionManagement
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
发现路径都是对的,但是就是扫描不到controller层
原因是maven多模块项目忘记引入子模块的maven依赖了,启动类是一个子模块,controller的代码是另外一个子模块,低级错误。