Startup Class Code
PackageCom.maven.demo;ImportOrg.mybatis.spring.annotation.MapperScan;Importorg.springframework.boot.SpringApplication;Importorg.springframework.boot.autoconfigure.EnableAutoConfiguration;Importorg.springframework.boot.autoconfigure.SpringBootApplication;ImportOrg.springframework.context.annotation.ComponentScan;Importorg.springframework.transaction.annotation.enabletransactionmanagement;@ Springbootapplication@enableautoconfiguration@componentscan ("Com.maven.demo") @MapperScan ("Com.maven.demo") @EnableTransactionManagement Public classDemoApplication { Public Static voidMain (string[] args) {Springapplication.run (demoapplication.class, args); }}
The discovery path is all right, but the controller layer is not scanned
The reason is that MAVEN multi-module project forgot to introduce the sub-module maven dependency, the Startup class is a submodule, controller's code is another sub-module, low-level error.
The Spring boot package does not scan the controller layer