Skip to content

Commit c61a60a

Browse files
committed
Initial commit
0 parents  commit c61a60a

File tree

8 files changed

+385
-0
lines changed

8 files changed

+385
-0
lines changed

.gitignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
target/
2+
!.mvn/wrapper/maven-wrapper.jar
3+
4+
### STS ###
5+
.apt_generated
6+
.classpath
7+
.factorypath
8+
.project
9+
.settings
10+
.springBeans
11+
.sts4-cache
12+
13+
### IntelliJ IDEA ###
14+
.idea
15+
*.iws
16+
*.iml
17+
*.ipr
18+
19+
### NetBeans ###
20+
nbproject/private/
21+
build/
22+
nbbuild/
23+
dist/
24+
nbdist/
25+
.nb-gradle/

pom.xml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>com.example</groupId>
7+
<artifactId>spring-cloud-client</artifactId>
8+
<version>0.0.1-SNAPSHOT</version>
9+
<packaging>jar</packaging>
10+
11+
<name>spring-cloud-client</name>
12+
<description>Demo project for spring-cloud</description>
13+
14+
<parent>
15+
<groupId>org.springframework.boot</groupId>
16+
<artifactId>spring-boot-starter-parent</artifactId>
17+
<version>2.0.0.RELEASE</version>
18+
<relativePath/> <!-- lookup parent from repository -->
19+
</parent>
20+
21+
<properties>
22+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
23+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
24+
<java.version>1.8</java.version>
25+
</properties>
26+
27+
<dependencies>
28+
<dependency>
29+
<groupId>org.springframework.boot</groupId>
30+
<artifactId>spring-boot-starter-web</artifactId>
31+
</dependency>
32+
33+
<dependency>
34+
<groupId>org.springframework.boot</groupId>
35+
<artifactId>spring-boot-starter-test</artifactId>
36+
<scope>test</scope>
37+
</dependency>
38+
39+
<dependency>
40+
<groupId>org.springframework.boot</groupId>
41+
<artifactId>spring-boot-devtools</artifactId>
42+
<scope>runtime</scope>
43+
</dependency>
44+
</dependencies>
45+
46+
<build>
47+
<plugins>
48+
<plugin>
49+
<groupId>org.springframework.boot</groupId>
50+
<artifactId>spring-boot-maven-plugin</artifactId>
51+
</plugin>
52+
</plugins>
53+
</build>
54+
55+
56+
</project>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.context.annotation.Bean;
6+
import org.springframework.web.client.RestTemplate;
7+
8+
@SpringBootApplication//
9+
//@ComponentScan("com.*")//因为SpringBootApplication已有该注解但默认扫同级下的包
10+
public class SpringCloudClientApplication {
11+
@Bean
12+
public RestTemplate restTemplate(){
13+
return new RestTemplate();
14+
}
15+
public static void main(String[] args) {
16+
SpringApplication.run(SpringCloudClientApplication.class, args);
17+
}
18+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.controller;
2+
3+
import com.domain.User;
4+
import org.springframework.beans.factory.annotation.Autowired;
5+
import org.springframework.stereotype.Controller;
6+
import org.springframework.web.bind.annotation.GetMapping;
7+
import org.springframework.web.bind.annotation.RequestMapping;
8+
import org.springframework.web.bind.annotation.ResponseBody;
9+
import org.springframework.web.client.RestTemplate;
10+
11+
/**
12+
* @author 73598.
13+
* @Date 2018/4/2 0002.
14+
* @Time 11:13.
15+
*/
16+
@Controller
17+
@RequestMapping("/client")
18+
//@RestController 的意思就是controller里面的方法都以json格式输出
19+
public class UserController {
20+
@Autowired
21+
RestTemplate restTemplate;
22+
23+
24+
@GetMapping("/test1")
25+
@ResponseBody
26+
public User getTest1(){
27+
User forObject = restTemplate.getForObject("http://localhost:8080/Test/test1", User.class);
28+
// System.out.println("123");
29+
return forObject;
30+
// System.out.println("123");
31+
// return "test2"+"123";
32+
}
33+
@GetMapping("/test2")
34+
@ResponseBody
35+
public String getTest2(){
36+
return "test2";
37+
}
38+
}

src/main/java/com/domain/Account.java

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package com.domain;
2+
3+
import java.math.BigDecimal;
4+
5+
/**
6+
* @author 73598.
7+
* @Date 2018/4/2 0002.
8+
* @Time 14:49.
9+
*/
10+
public class Account {
11+
private BigDecimal balance ;
12+
private Long id;
13+
private String userId;
14+
15+
public BigDecimal getBalance() {
16+
return balance;
17+
}
18+
19+
public void setBalance(BigDecimal balance) {
20+
this.balance = balance;
21+
}
22+
23+
public Long getId() {
24+
return id;
25+
}
26+
27+
public void setId(Long id) {
28+
this.id = id;
29+
}
30+
31+
public String getUserId() {
32+
return userId;
33+
}
34+
35+
public void setUserId(String userId) {
36+
this.userId = userId;
37+
}
38+
39+
@Override
40+
public String toString() {
41+
return "Account{" +
42+
"balance=" + balance +
43+
", id=" + id +
44+
", userId='" + userId + '\'' +
45+
'}';
46+
}
47+
}

src/main/java/com/domain/User.java

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
package com.domain;
2+
3+
import java.util.Date;
4+
5+
/**
6+
* 用户表
7+
* @author 73598 2018-03-09
8+
*/
9+
public class User {
10+
/**
11+
* 自增ID
12+
*/
13+
private Long id;
14+
15+
/**
16+
* 用户名
17+
*/
18+
private String loginName;
19+
20+
/**
21+
* 登陆密码
22+
*/
23+
private String password;
24+
25+
/**
26+
* 用户昵称
27+
*/
28+
private String username;
29+
30+
/**
31+
*
32+
*/
33+
private String isDeleted;
34+
35+
/**
36+
* 邮件
37+
*/
38+
private String email;
39+
40+
/**
41+
* 移动电话
42+
*/
43+
private String mobile;
44+
45+
/**
46+
* 记录创建时间
47+
*/
48+
private Date gmtCreate;
49+
50+
/**
51+
* 最近更新时间
52+
*/
53+
private Date gmtModified;
54+
55+
/**
56+
* 区
57+
*/
58+
private String locationArea;
59+
60+
/**
61+
* 市
62+
*/
63+
private String locationCity;
64+
65+
/**
66+
* 省
67+
*/
68+
private String locationProvince;
69+
70+
public Long getId() {
71+
return id;
72+
}
73+
74+
public void setId(Long id) {
75+
this.id = id;
76+
}
77+
78+
public String getLoginName() {
79+
return loginName;
80+
}
81+
82+
public void setLoginName(String loginName) {
83+
this.loginName = loginName == null ? null : loginName.trim();
84+
}
85+
86+
public String getPassword() {
87+
return password;
88+
}
89+
90+
public void setPassword(String password) {
91+
this.password = password == null ? null : password.trim();
92+
}
93+
94+
public String getUsername() {
95+
return username;
96+
}
97+
98+
public void setUsername(String username) {
99+
this.username = username == null ? null : username.trim();
100+
}
101+
102+
public String getIsDeleted() {
103+
return isDeleted;
104+
}
105+
106+
public void setIsDeleted(String isDeleted) {
107+
this.isDeleted = isDeleted == null ? null : isDeleted.trim();
108+
}
109+
110+
public String getEmail() {
111+
return email;
112+
}
113+
114+
public void setEmail(String email) {
115+
this.email = email == null ? null : email.trim();
116+
}
117+
118+
public String getMobile() {
119+
return mobile;
120+
}
121+
122+
public void setMobile(String mobile) {
123+
this.mobile = mobile == null ? null : mobile.trim();
124+
}
125+
126+
public Date getGmtCreate() {
127+
return gmtCreate;
128+
}
129+
130+
public void setGmtCreate(Date gmtCreate) {
131+
this.gmtCreate = gmtCreate;
132+
}
133+
134+
public Date getGmtModified() {
135+
return gmtModified;
136+
}
137+
138+
public void setGmtModified(Date gmtModified) {
139+
this.gmtModified = gmtModified;
140+
}
141+
142+
public String getLocationArea() {
143+
return locationArea;
144+
}
145+
146+
public void setLocationArea(String locationArea) {
147+
this.locationArea = locationArea == null ? null : locationArea.trim();
148+
}
149+
150+
public String getLocationCity() {
151+
return locationCity;
152+
}
153+
154+
public void setLocationCity(String locationCity) {
155+
this.locationCity = locationCity == null ? null : locationCity.trim();
156+
}
157+
158+
public String getLocationProvince() {
159+
return locationProvince;
160+
}
161+
162+
public void setLocationProvince(String locationProvince) {
163+
this.locationProvince = locationProvince == null ? null : locationProvince.trim();
164+
}
165+
166+
@Override
167+
public String toString() {
168+
return "User{" +
169+
"id=" + id +
170+
", loginName='" + loginName + '\'' +
171+
", password='" + password + '\'' +
172+
", username='" + username + '\'' +
173+
", isDeleted='" + isDeleted + '\'' +
174+
", email='" + email + '\'' +
175+
", mobile='" + mobile + '\'' +
176+
", gmtCreate=" + gmtCreate +
177+
", gmtModified=" + gmtModified +
178+
", locationArea='" + locationArea + '\'' +
179+
", locationCity='" + locationCity + '\'' +
180+
", locationProvince='" + locationProvince + '\'' +
181+
'}';
182+
}
183+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
server.port=8010
2+
logging.level.root=info
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.example.springcloudclient;
2+
3+
import org.junit.Test;
4+
import org.junit.runner.RunWith;
5+
import org.springframework.boot.test.context.SpringBootTest;
6+
import org.springframework.test.context.junit4.SpringRunner;
7+
8+
@RunWith(SpringRunner.class)
9+
@SpringBootTest
10+
public class SpringCloudClientApplicationTests {
11+
12+
@Test
13+
public void contextLoads() {
14+
}
15+
16+
}

0 commit comments

Comments
 (0)