Idea SpringBoot 子模块 加载不到该子模块根目录config下面的配置文件
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 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扫码目录需要将子模块中的路径也一起加进来。
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); } }
分类:
spring
, idea&eclipse&jdk
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· DeepSeek在M芯片Mac上本地化部署
2022-01-15 Excel表格Vlookup跨sheet取值,ISNA函数处理匹配不到的空字符串
2022-01-15 如何查询Windows10的激活时间等相关信息