随笔 - 547  文章 - 1  评论 - 292  阅读 - 33万

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);
    }
}
复制代码

 

posted on   oktokeep  阅读(398)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 【自荐】一款简洁、开源的在线白板工具 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的激活时间等相关信息
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示