@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class,
HibernateJpaAutoConfiguration.class})
public class AssemblyApplication {
private static final Logger logger = LoggerFactory.getLogger(AssemblyApplication.class);
public static void main(String[] args) throws Exception {
ConfigurableApplicationContext commonContext =
new SpringApplicationBuilder(AssemblyApplication.class).web(false).run(args);
commonContext.addApplicationListener(new ApplicationPidFileWriter());
// Run configservice
if (commonContext.getEnvironment().containsProperty("configservice")) {
ConfigurableApplicationContext configContext =
new SpringApplicationBuilder(ConfigServiceApplication.class).parent(commonContext)
.sources(RefreshScope.class).run(args);
}
// Run adminservice
if (commonContext.getEnvironment().containsProperty("adminservice")) {
ConfigurableApplicationContext adminContext =
new SpringApplicationBuilder(AdminServiceApplication.class).parent(commonContext)
.sources(RefreshScope.class).run(args);
}
// Run portal
if (commonContext.getEnvironment().containsProperty("portal")) {
ConfigurableApplicationContext portalContext =
new SpringApplicationBuilder(PortalApplication.class).parent(commonContext)
.sources(RefreshScope.class).run(args);
}
}
}
configservice:
-configservice
-src
-main
-java
-resources
-liquibase
-changelog.xml
-application.yml
-bootstrap.yml
adminservice:
-adminservice
-src
-main
-java
-resources
-application.yml
-bootstrap.yml
portal:
-portal
-src
-main
-java
-resources
-liquibase
-changelog.xml
-application.yml
endpoints:
health:
sensitive: false
management:
security:
enabled: false
health:
status:
order: DOWN, OUT_OF_SERVICE, UNKNOWN, UP
spring:
datasource:
continue-on-error: true
platform: h2
jpa:
show-sql: true
properties:
hibernate:
dialect: org.hibernate.dialect.H2Dialect
hibernate:
ddl-auto: none
liquibase:
change-log: classpath:liquibase/changelog.xml
user:
password:
url:
${spring_datasource_url:jdbc:h2:~/.h2/default/configdb;AUTO_SERVER=TRUE}
enabled: true
drop-first: false
configservice的application.yml
spring:
application:
name: configservice
profiles:
active: ${active_profile}
server:
port: ${config_port:8330}
logging:
file: /opt/logs/configservice.log
门户网站的application.yml
spring:
application:
name: portal
profiles:
active: ${active_profile}
datasource:
continue-on-error: true
platform: h2
jpa:
show-sql: true
properties:
hibernate:
dialect: org.hibernate.dialect.H2Dialect
hibernate:
ddl-auto: none
server:
port: 9080
logging:
file: /opt/logs/100003173/portal.log
endpoints:
health:
sensitive: false
management:
security:
enabled: false
health:
status:
order: DOWN, OUT_OF_SERVICE, UNKNOWN, UP
liquibase:
change-log: classpath:liquibase/changelog.xml
user:
password:
url: ${spring_datasource_url}
enabled: true
drop-first: false
答案 0 :(得分:0)
configservice.jar(或您的构建工件所命名的任何名称)是类路径中的第一个,并且获胜。
您应该外部化配置,或者在每个模块中以不同的方式命名属性文件。
如何使用其他名称,您可以在这里找到:
http://roufid.com/rename-spring-boot-application-properties/