提交 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 {
.sources(RefreshScope.class).run(args);
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;
@Configuration
@EnableAutoConfiguration
@EnableTransactionManagement
@PropertySource(value = {"classpath:portal.properties"})
@ComponentScan(basePackageClasses = {ApolloCommonConfig.class,
PortalApplication.class})
public class PortalApplication {
......
......@@ -35,7 +35,6 @@ public class PortalSettings {
private static final int HEALTH_CHECK_INTERVAL = 5000;
@Value("#{'${apollo.portal.envs}'.split(',')}")
private List<String> allStrEnvs;
@Autowired
......
......@@ -4,6 +4,7 @@ import com.ctrip.framework.apollo.portal.entity.po.ServerConfig;
import com.ctrip.framework.apollo.portal.repository.ServerConfigRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
/**
......@@ -14,7 +15,14 @@ public class ServerConfigService {
@Autowired
private ServerConfigRepository serverConfigRepository;
@Autowired
private Environment environment;
public String getValue(String key) {
if (environment.containsProperty(key)) {
return environment.getProperty(key);
}
ServerConfig serverConfig = serverConfigRepository.findByKey(key);
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.
先完成此消息的编辑!
想要评论请 注册