Commit 4f653461 by Yiming Liu

Enable local start config/admin/portal

parent 43434383
......@@ -10,12 +10,14 @@ import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.PropertySource;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@EnableAspectJAutoProxy
@EnableEurekaClient
@Configuration
@PropertySource(value = {"classpath:adminservice.properties"})
@EnableAutoConfiguration
@EnableTransactionManagement
@ComponentScan(basePackageClasses = {com.ctrip.apollo.common.ApolloCommonConfig.class,
com.ctrip.apollo.biz.ApolloBizConfig.class,
com.ctrip.apollo.adminservice.AdminServiceApplication.class})
......
package com.ctrip.apollo.adminservice.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping(path = "/")
public class IndexController {
@RequestMapping(path = "")
public String index() {
return "apollo-adminservice";
}
}
......@@ -12,7 +12,7 @@ import com.ctrip.apollo.adminservice.AdminServiceApplication;
@Configuration
@ComponentScan(excludeFilters = {@Filter(type = FilterType.ASSIGNABLE_TYPE, value = {
SampleAdminServiceApplication.class, AdminServiceApplication.class,
LocalAdminServiceApplication.class, AdminServiceApplication.class,
HttpMessageConverterConfiguration.class})})
@EnableAutoConfiguration
public class AdminServiceTestConfiguration {
......
......@@ -6,8 +6,8 @@ import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@SpringBootApplication
@EnableEurekaServer
public class SampleAdminServiceApplication {
public class LocalAdminServiceApplication {
public static void main(String[] args) {
new SpringApplicationBuilder(SampleAdminServiceApplication.class).run(args);
new SpringApplicationBuilder(LocalAdminServiceApplication.class).run(args);
}
}
......@@ -3,7 +3,6 @@ package com.ctrip.apollo.assembly;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.actuate.system.ApplicationPidFileWriter;
import org.springframework.boot.actuate.system.EmbeddedServerPortFileWriter;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
......
package com.ctrip.apollo.assembly;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.actuate.system.ApplicationPidFileWriter;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.context.scope.refresh.RefreshScope;
import org.springframework.context.ConfigurableApplicationContext;
import com.ctrip.apollo.adminservice.AdminServiceApplication;
import com.ctrip.apollo.configservice.ConfigServiceApplication;
import com.ctrip.apollo.portal.PortalApplication;
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class,
HibernateJpaAutoConfiguration.class})
public class LocalApolloApplication {
private static final Logger logger = LoggerFactory.getLogger(ApolloApplication.class);
public static void main(String[] args) throws Exception {
/**
* Common
*/
ConfigurableApplicationContext commonContext =
new SpringApplicationBuilder(ApolloApplication.class).web(false).run(args);
commonContext.addApplicationListener(new ApplicationPidFileWriter());
logger.info(commonContext.getId() + " isActive: " + commonContext.isActive());
/**
* ConfigService
*/
if (commonContext.getEnvironment().containsProperty("configservice")) {
ConfigurableApplicationContext configContext =
new SpringApplicationBuilder(ConfigServiceApplication.class).parent(commonContext)
.sources(RefreshScope.class).run(args);
logger.info(configContext.getId() + " isActive: " + configContext.isActive());
}
/**
* AdminService
*/
if (commonContext.getEnvironment().containsProperty("adminservice")) {
ConfigurableApplicationContext adminContext =
new SpringApplicationBuilder(AdminServiceApplication.class).parent(commonContext)
.sources(RefreshScope.class).run(args);
logger.info(adminContext.getId() + " isActive: " + adminContext.isActive());
}
/**
* Portal
*/
if (commonContext.getEnvironment().containsProperty("portal")) {
ConfigurableApplicationContext portalContext =
new SpringApplicationBuilder(PortalApplication.class).parent(commonContext).run(args);
logger.info(portalContext.getId() + " isActive: " + portalContext.isActive());
}
}
}
spring.datasource.url = jdbc:h2:mem:~/apolloconfigdb;mode=mysql;DB_CLOSE_ON_EXIT=FALSE
spring.jpa.hibernate.naming_strategy=org.hibernate.cfg.EJB3NamingStrategy
spring.jpa.properties.hibernate.show_sql=true
spring.h2.console.enabled = true
spring.h2.console.settings.web-allow-others=true
apollo.portal.env= local
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true">
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<charset>utf-8</charset>
<Pattern>[%p] %c - %m%n</Pattern>
</encoder>
</appender>
<logger name="org.springframework.test" level="OFF" />
<root level="INFO">
<appender-ref ref="CONSOLE" />
</root>
</configuration>
\ No newline at end of file
package com.ctrip.apollo.common.controller;
import javax.servlet.DispatcherType;
import org.springframework.boot.context.embedded.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.filter.CharacterEncodingFilter;
@Configuration
public class CharacterEncodingFilterConfiguration {
@Bean
public FilterRegistrationBean encodingFilter() {
FilterRegistrationBean bean = new FilterRegistrationBean();
bean.setFilter(new CharacterEncodingFilter());
bean.addInitParameter("encoding", "UTF-8");
//FIXME: https://github.com/Netflix/eureka/issues/702
// bean.addInitParameter("forceEncoding", "true");
bean.setName("encodingFilter");
bean.addUrlPatterns("/*");
bean.setDispatcherTypes(DispatcherType.REQUEST, DispatcherType.FORWARD);
return bean;
}
}
package com.ctrip.apollo.common.controller;
import java.util.List;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.web.PageableHandlerMethodArgumentResolver;
......@@ -8,8 +10,6 @@ import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import java.util.List;
@Configuration
public class WebMvcConfig extends WebMvcConfigurerAdapter {
......
spring.http.converters.preferred-json-mapper=gson
\ No newline at end of file
......@@ -10,6 +10,7 @@ import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.transaction.annotation.EnableTransactionManagement;
/**
* Spring boot application entry point
......@@ -19,12 +20,14 @@ import org.springframework.context.annotation.PropertySource;
@EnableEurekaServer
@EnableAspectJAutoProxy
@EnableAutoConfiguration//(exclude = EurekaClientConfigBean.class)
@EnableAutoConfiguration // (exclude = EurekaClientConfigBean.class)
@Configuration
@EnableTransactionManagement
@PropertySource(value = {"classpath:configservice.properties"})
@ComponentScan(basePackageClasses = {com.ctrip.apollo.common.ApolloCommonConfig.class,
com.ctrip.apollo.biz.ApolloBizConfig.class,
com.ctrip.apollo.configservice.ConfigServiceApplication.class})
com.ctrip.apollo.configservice.ConfigServiceApplication.class,
com.ctrip.apollo.metaservice.ApolloMetaServiceConfig.class})
public class ConfigServiceApplication {
public static void main(String[] args) throws Exception {
......
package com.ctrip.apollo.metaservice;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@EnableAutoConfiguration
@Configuration
@ComponentScan(basePackageClasses = com.ctrip.apollo.metaservice.ApolloMetaServiceConfig.class)
public class ApolloMetaServiceConfig {
}
......@@ -11,7 +11,7 @@ import org.springframework.context.annotation.FilterType;
@Configuration
@ComponentScan(excludeFilters = {@Filter(type = FilterType.ASSIGNABLE_TYPE, value = {
SampleConfigServiceApplication.class, ConfigServiceApplication.class, WebSecurityConfig.class})})
LocalConfigServiceApplication.class, ConfigServiceApplication.class, WebSecurityConfig.class})})
@EnableAutoConfiguration
public class ConfigServiceTestConfiguration {
......
......@@ -6,8 +6,8 @@ import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@SpringBootApplication
@EnableEurekaServer
public class SampleConfigServiceApplication {
public class LocalConfigServiceApplication {
public static void main(String[] args) {
new SpringApplicationBuilder(SampleConfigServiceApplication.class).run(args);
new SpringApplicationBuilder(LocalConfigServiceApplication.class).run(args);
}
}
......@@ -4,8 +4,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
@SpringBootApplication
public class SamplePortalApplication {
public class LocalPortalApplication {
public static void main(String[] args) {
new SpringApplicationBuilder(SamplePortalApplication.class).run(args);
new SpringApplicationBuilder(LocalPortalApplication.class).run(args);
}
}
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