提交 af089bd8 编写于 作者: 张乐 提交者: GitHub

Merge pull request #291 from nobodyiam/support-system-property-as-server-config

support system property as server config
...@@ -48,17 +48,6 @@ public class ApolloApplication { ...@@ -48,17 +48,6 @@ public class ApolloApplication {
.sources(RefreshScope.class).run(args); .sources(RefreshScope.class).run(args);
logger.info(adminContext.getId() + " isActive: " + adminContext.isActive()); logger.info(adminContext.getId() + " isActive: " + adminContext.isActive());
} }
/**
* Portal
*
* WARNING: Do not start portal at the same pool as configservice, they will conflict on 8080
*/
if (commonContext.getEnvironment().containsProperty("portal")) {
ConfigurableApplicationContext portalContext =
new SpringApplicationBuilder(PortalApplication.class).parent(commonContext).run(args);
logger.info(portalContext.getId() + " isActive: " + portalContext.isActive());
}
} }
} }
...@@ -17,7 +17,6 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; ...@@ -17,7 +17,6 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@Configuration @Configuration
@EnableAutoConfiguration @EnableAutoConfiguration
@EnableTransactionManagement @EnableTransactionManagement
@PropertySource(value = {"classpath:portal.properties"})
@ComponentScan(basePackageClasses = {ApolloCommonConfig.class, @ComponentScan(basePackageClasses = {ApolloCommonConfig.class,
PortalApplication.class}) PortalApplication.class})
public class PortalApplication { public class PortalApplication {
......
...@@ -35,7 +35,6 @@ public class PortalSettings { ...@@ -35,7 +35,6 @@ public class PortalSettings {
private static final int HEALTH_CHECK_INTERVAL = 5000; private static final int HEALTH_CHECK_INTERVAL = 5000;
@Value("#{'${apollo.portal.envs}'.split(',')}")
private List<String> allStrEnvs; private List<String> allStrEnvs;
@Autowired @Autowired
......
...@@ -4,6 +4,7 @@ import com.ctrip.framework.apollo.portal.entity.po.ServerConfig; ...@@ -4,6 +4,7 @@ import com.ctrip.framework.apollo.portal.entity.po.ServerConfig;
import com.ctrip.framework.apollo.portal.repository.ServerConfigRepository; import com.ctrip.framework.apollo.portal.repository.ServerConfigRepository;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
/** /**
...@@ -14,7 +15,14 @@ public class ServerConfigService { ...@@ -14,7 +15,14 @@ public class ServerConfigService {
@Autowired @Autowired
private ServerConfigRepository serverConfigRepository; private ServerConfigRepository serverConfigRepository;
@Autowired
private Environment environment;
public String getValue(String key) { public String getValue(String key) {
if (environment.containsProperty(key)) {
return environment.getProperty(key);
}
ServerConfig serverConfig = serverConfigRepository.findByKey(key); ServerConfig serverConfig = serverConfigRepository.findByKey(key);
return serverConfig == null ? null : serverConfig.getValue(); return serverConfig == null ? null : serverConfig.getValue();
......
spring.application.name= apollo-portal
apollo.portal.envs= fat,uat,pro
ctrip.appid= 100003173
server.port= 8070
logging.file= /opt/logs/100003173/apollo-portal.log
server.context_parameters.appid = ${ctrip.appid}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册