Idea SpringBoot 子模块 加载不到该子模块根目录config下面的配置文件
import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.support.SpringBootServletInitializer; import org.springframework.cloud.netflix.eureka.EnableEurekaClient; import org.springframework.cloud.netflix.feign.EnableFeignClients; import org.springframework.retry.annotation.EnableRetry; /** * 本机单元测试类时候,打开,在子模块中运行该模块的项目。 */ //@EnableAsync //@EnableRetry //@EnableFeignClients({"com.mytest"}) //@EnableEurekaClient ////@SpringBootApplication //@SpringBootApplication(scanBasePackages = {"com.mytest.insure"}) //@MapperScan({"com.mytest.insure.mapper"}) //public class AutoInsureApplication extends SpringBootServletInitializer { // // @Override // protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { // return application.sources(AutoInsureApplication.class); // } // // public static void main(String[] args) { // SpringApplication.run(AutoInsureApplication.class, args); // } //}
//主项目的启动文件,SpringBootApplication和MapperScan扫码目录需要将子模块中的路径也一起加进来。
import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.support.SpringBootServletInitializer; import org.springframework.cloud.netflix.eureka.EnableEurekaClient; import org.springframework.cloud.netflix.feign.EnableFeignClients; import org.springframework.retry.annotation.EnableRetry; import org.springframework.scheduling.annotation.EnableAsync; @EnableAsync @EnableRetry @EnableFeignClients({"com.mytest","com.mytest.config","com.mytest.order.open"}) @EnableEurekaClient //@SpringBootApplication @SpringBootApplication(scanBasePackages = {"com.mytest.insurance","com.mytest.insure"}) @MapperScan({"com.mytest.insurance.mapper","com.mytest.insure.mapper"}) public class InsurancePurchaseApplication extends SpringBootServletInitializer { @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(InsurancePurchaseApplication.class); } public static void main(String[] args) { SpringApplication.run(InsurancePurchaseApplication.class, args); } }
标签:配置文件,mytest,import,boot,springframework,模块,org,根目录,com From: https://www.cnblogs.com/oktokeep/p/17966055