Idea SpringBoot 子模块 加载不到该子模块根目录config下面的配置文件
代码语言:javascript复制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 MyModuleApplication extends SpringBootServletInitializer {
//
// @Override
// protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
// return application.sources(MyModuleApplication.class);
// }
//
// public static void main(String[] args) {
// SpringApplication.run(MyModuleApplication.class, args);
// }
//}
//主项目的启动文件,SpringBootApplication和MapperScan扫码目录需要将子模块中的路径也一起加进来。
代码语言:javascript复制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 MyMainProjectApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(MyMainProjectApplication.class);
}
public static void main(String[] args) {
SpringApplication.run(MyMainProjectApplication.class, args);
}
}