增加spring cloud config的测试配置
This commit is contained in:
@ -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
|
Reference in New Issue
Block a user