相关疑难解决方法(0)

Spring Boot从依赖项继承application.properties

假设我有5个Spring Boot项目.所有这些都有一个Maven依赖于Spring Boot项目No 6和一些共享/公共类.5个独立项目在每个application.properties上分配了许多公共属性,我想将它们抽象并移动到公共项目中.整体看起来像这样:

                                            Project 1 (app.properties)
Common Project (app-common.properties) <--- Project 2 (app.properties)
                                            Project 3 (app.properties)...
Run Code Online (Sandbox Code Playgroud)

当前的问题是app-common.properties位于project1.jar/lib/common-project.jar中,而app-common.properties显然不会在启动时加载.

有没有办法从依赖中扩展它?

CommonProject Main类如下所示:

@SpringBootApplication
public class CommonApplication extends SpringBootServletInitializer {

    protected static void run(SpringApplication application, String[] args) {
        application.run(args);
    }
}
Run Code Online (Sandbox Code Playgroud)

Project1主类看起来像这样:

public class Project1 extends CommonApplication {

    public static void main(String[] args) {
        run(new SpringApplication(Project1.class), args);
    }
}
Run Code Online (Sandbox Code Playgroud)

spring spring-boot

16
推荐指数
2
解决办法
1万
查看次数

标签 统计

spring ×1

spring-boot ×1