Commit 883ded6b authored by houg's avatar houg

apollo

parent 05cf1163
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion>
<modelVersion>4.0.0</modelVersion>
<groupId>com.test</groupId> <groupId>com.test</groupId>
<artifactId>eureka-server</artifactId> <artifactId>eureka-server</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>eureka-server</name> <name>eureka-server</name>
<description>Demo project for Spring Boot</description> <description>Demo project for Spring Boot</description>
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.5.RELEASE</version> <version>2.1.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository --> <relativePath /> <!-- lookup parent from repository -->
</parent> </parent>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version> <java.version>1.8</java.version>
<spring-cloud.version>Finchley.RC2</spring-cloud.version> <spring-cloud.version>Finchley.RC2</spring-cloud.version>
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter</artifactId> <artifactId>spring-cloud-starter</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId> <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId> <artifactId>spring-boot-starter-security</artifactId>
</dependency> </dependency>
</dependencies> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependencyManagement> <dependency>
<dependencies> <groupId>com.ctrip.framework.apollo</groupId>
<dependency> <artifactId>apollo-client</artifactId>
<groupId>org.springframework.cloud</groupId> <version>1.1.1</version>
<artifactId>spring-cloud-dependencies</artifactId> </dependency>
<version>${spring-cloud.version}</version> <dependency>
<type>pom</type> <groupId>org.springframework.boot</groupId>
<scope>import</scope> <artifactId>spring-boot-starter-data-rest</artifactId>
</dependency> </dependency>
</dependencies> </dependencies>
</dependencyManagement>
<build> <dependencyManagement>
<plugins> <dependencies>
<plugin> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-cloud-dependencies</artifactId>
<executions> <version>${spring-cloud.version}</version>
<execution> <type>pom</type>
<goals> <scope>import</scope>
<goal>build-info</goal> </dependency>
</goals> </dependencies>
</execution> </dependencyManagement>
</executions>
</plugin>
</plugins>
</build>
<repositories> <build>
<repository> <plugins>
<id>central</id> <plugin>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url> <groupId>org.springframework.boot</groupId>
<name>aliyun</name> <artifactId>spring-boot-maven-plugin</artifactId>
</repository> <executions>
<repository> <execution>
<id>spring-milestones</id> <goals>
<name>Spring Milestones</name> <goal>build-info</goal>
<url>https://repo.spring.io/milestone</url> </goals>
<snapshots> </execution>
<enabled>false</enabled> </executions>
</snapshots> </plugin>
</repository> </plugins>
</repositories> </build>
<repositories>
<repository>
<id>central</id>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<name>aliyun</name>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</project> </project>
...@@ -7,24 +7,27 @@ import org.springframework.context.annotation.Configuration; ...@@ -7,24 +7,27 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig;
/** /**
* @author Ryan * @author Ryan
*/ */
@EnableEurekaServer @EnableEurekaServer
@SpringBootApplication @SpringBootApplication
@EnableApolloConfig
public class EurekaServerApplication { public class EurekaServerApplication {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(EurekaServerApplication.class, args); SpringApplication.run(EurekaServerApplication.class, args);
} }
@Configuration @Configuration
public static class SecurityPermitAllConfig extends WebSecurityConfigurerAdapter { public static class SecurityPermitAllConfig extends WebSecurityConfigurerAdapter {
@Override @Override
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().anyRequest().permitAll()// http.authorizeRequests().anyRequest().permitAll()//
.and().csrf().disable(); .and().csrf().disable();
} }
} }
} }
package com.enovate.newretail.eureka;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.spring.annotation.ApolloConfig;
@RestController
@RequestMapping(path = "/config")
public class TestController {
@ApolloConfig
private Config config;
@RequestMapping(path = "/get/{key}", method = {RequestMethod.GET, RequestMethod.POST})
public String get(@PathVariable("key") String key) {
return config.getProperty(key, config.getSourceType().name());
}
}
dev.meta=http://132.232.68.227:8080
fat.meta=http://172.21.28.19:8080
uat.meta=http://192.168.1.38:8082
pro.meta=http://192.168.1.38:8083
\ No newline at end of file
spring.application.name=eureka-server spring.application.name=eureka-server
server.port=8761 server.port=8761
app.id=evonate-newretail-eureka
apollo.meta=http://192.168.1.38:8080
#spring.profiles.active = apollo-env.properties
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