Commit eda9fd7d by Jason Song

support system property as server config

parent 99a2cf04
......@@ -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% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment