增加spring cloud config的测试配置
This commit is contained in:
parent
7000487859
commit
312f219451
@ -28,6 +28,12 @@
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<dependencyManagement>
|
||||
|
@ -0,0 +1,28 @@
|
||||
package com.heibaiying.config.server.config;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "programmer")
|
||||
@Data
|
||||
@ToString
|
||||
public class Programmer {
|
||||
|
||||
private String name;
|
||||
private int age;
|
||||
private boolean married;
|
||||
private Date hireDate;
|
||||
private float salary;
|
||||
private int random;
|
||||
private Map<String, String> skill;
|
||||
private List company;
|
||||
private School school;
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.heibaiying.config.server.config;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author : heibaiying
|
||||
*/
|
||||
@Data
|
||||
public class School {
|
||||
private String name;
|
||||
private String location;
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.heibaiying.config.server.controller;
|
||||
|
||||
import com.heibaiying.config.server.config.Programmer;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author : heibaiying
|
||||
*/
|
||||
|
||||
@RestController
|
||||
public class ConfigController {
|
||||
|
||||
@Autowired
|
||||
private Programmer programmer;
|
||||
|
||||
@RequestMapping("programmer")
|
||||
public Programmer getProgrammer(){
|
||||
return programmer;
|
||||
}
|
||||
}
|
@ -8,7 +8,8 @@ spring:
|
||||
server:
|
||||
git:
|
||||
uri: https://github.com/heibaiying/spring-samples-for-all/
|
||||
search-paths: spring-cloud/spring-cloud-eureka-cluster/eureka-server/src/main/resources/
|
||||
search-paths: spring-cloud/spring-cloud-test-config/
|
||||
# 如果代码仓库是公开的 则 不需要设置用户名和密码
|
||||
username:
|
||||
password:
|
||||
label: master
|
20
spring-cloud/spring-cloud-test-config/application-dev.yml
Normal file
20
spring-cloud/spring-cloud-test-config/application-dev.yml
Normal file
@ -0,0 +1,20 @@
|
||||
spring:
|
||||
application:
|
||||
name: server
|
||||
server:
|
||||
port: 8010
|
||||
eureka:
|
||||
server:
|
||||
# 关闭自我保护机制 开发的时候可以开启 保证不可用的服务能够及时剔除
|
||||
enable-self-preservation: false
|
||||
instance:
|
||||
hostname: 127.0.0.1
|
||||
client:
|
||||
serviceUrl:
|
||||
defaultZone: http://localhost:8020/eureka/,http://192.168.200.228:8030/eureka/
|
||||
|
||||
|
||||
programmer:
|
||||
school:
|
||||
name: unviersity
|
||||
location: shanghai
|
24
spring-cloud/spring-cloud-test-config/application.yml
Normal file
24
spring-cloud/spring-cloud-test-config/application.yml
Normal file
@ -0,0 +1,24 @@
|
||||
spring:
|
||||
application:
|
||||
name: server
|
||||
server:
|
||||
port: 8010
|
||||
eureka:
|
||||
server:
|
||||
# 关闭自我保护机制 开发的时候可以开启 保证不可用的服务能够及时剔除
|
||||
enable-self-preservation: false
|
||||
instance:
|
||||
hostname: 127.0.0.1
|
||||
client:
|
||||
serviceUrl:
|
||||
defaultZone: http://localhost:8020/eureka/,http://192.168.200.228:8030/eureka/
|
||||
|
||||
|
||||
programmer:
|
||||
name: xiaoming
|
||||
married: false
|
||||
hireDate: 2018/12/23
|
||||
salary: 66666.88
|
||||
random: ${random.int[1024,65536]}
|
||||
skill: {java: master, jquery: proficiency}
|
||||
company: [baidu,tengxun,alibaba]
|
Loading…
x
Reference in New Issue
Block a user