Skip to content

Commit

Permalink
提交
Browse files Browse the repository at this point in the history
  • Loading branch information
gongxings committed Mar 30, 2019
1 parent 5a239ff commit 7781f8e
Show file tree
Hide file tree
Showing 17 changed files with 858 additions and 0 deletions.
78 changes: 78 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" 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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.gxs.springcloud</groupId>
<artifactId>springcloud-study</artifactId>
<version>1.0-SNAPSHOT</version>
<modules>
<module>springcloud-study-api</module>
<module>springcloud-study-provider-dept-8001</module>
<module>springcloud-study-consumer-dept-80</module>
</modules>
<packaging>pom</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<junit.version>4.12</junit.version>
<log4j.version>1.2.17</log4j.version>
<druid.version>1.1.10</druid.version>
<spring-boot.version>1.5.19.RELEASE</spring-boot.version>
<spring-cloud.version>Dalston.SR1</spring-cloud.version>
<mysql-connector.version>5.1.47</mysql-connector.version>
<mybatis-starter.version>1.3.3</mybatis-starter.version>
<logback.version>1.2.3</logback.version>
<lombok.version>1.18.6</lombok.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql-connector.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>${druid.version}</version>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>${mybatis-starter.version}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>
23 changes: 23 additions & 0 deletions springcloud-study-api/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" 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">

<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.gxs.springcloud</groupId>
<artifactId>springcloud-study</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>springcloud-study-api</artifactId>

<dependencies>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.gxs.springcloud.entities;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.io.Serializable;

/**
* @author GongXings
* @createTime 30 13:44
* @description 部门实体类
*/
@AllArgsConstructor
@NoArgsConstructor
@Data
@Accessors(chain = true)
public class DeptEntity implements Serializable{
/**
* 部门编码 主键
*/
private Long deptNo;
/**
* 部门名称
*/
private String deptName;
/**
* 数据库名称
*/
private String dbSource;

}
54 changes: 54 additions & 0 deletions springcloud-study-consumer-dept-80/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" 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">

<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.gxs.springcloud</groupId>
<artifactId>springcloud-study</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>springcloud-study-consumer-dept-80</artifactId>

<dependencies>
<dependency>
<groupId>com.gxs.springcloud</groupId>
<artifactId>springcloud-study-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<!--热部署 修改后立即生效-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>

</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.gxs.springcloud;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
* @author GongXings
* @createTime 30 16:11
* @description
*/
@SpringBootApplication
public class DeptConsumer80App {
public static void main(String[] args) {
SpringApplication.run(DeptConsumer80App.class,args);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.gxs.springcloud.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
* @author GongXings
* @createTime 30 15:43
* @description
*/
@Configuration
public class ConfigBean {

/**
* 配置RestTemplate
* 通过RestTemplate调用提供者服务 ,发送rest请求
* 提供了多种访问http服务的方法,
* 针对于访问rest服务<strong>客户端</strong>的调用的模板类
* @return
*/
@Bean
public RestTemplate getRestTemplate(){
return new RestTemplate();
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.gxs.springcloud.controller;

import com.gxs.springcloud.entities.DeptEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.List;

/**
* @author GongXings
* @createTime 30 15:48
* @description
*/
@RestController
public class DeptConsumerController {

private static final String REST_URL_PREFIX="http://localhost:8001";

@Autowired
private RestTemplate restTemplate;

@RequestMapping(value = "/consumer/dept/add")
public boolean add( DeptEntity deptEntity){
//三个参数:url,requestMap ResponseBean.class
return restTemplate.postForObject(
REST_URL_PREFIX+"/dept/add",
deptEntity,
Boolean.class);
}

@RequestMapping("/consumer/dept/findById/{deptNo}")
public DeptEntity findById(Long deptNo){
//三个参数:url,requestMap ResponseBean.class
return restTemplate.getForObject(
REST_URL_PREFIX+"/dept/findById/"+deptNo,
DeptEntity.class);
}

@RequestMapping("/consumer/dept/findAll")
public List findAll(){
//三个参数:url,requestMap ResponseBean.class
return restTemplate.getForObject(
REST_URL_PREFIX+"/dept/findAll",
List.class);
}
}
64 changes: 64 additions & 0 deletions springcloud-study-provider-dept-8001/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" 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">

<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.gxs.springcloud</groupId>
<artifactId>springcloud-study</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>springcloud-study-provider-dept-8001</artifactId>

<dependencies>
<dependency>
<groupId>com.gxs.springcloud</groupId>
<artifactId>springcloud-study-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<!--热部署 修改后立即生效-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>

</dependencies>

</project>
Loading

0 comments on commit 7781f8e

Please sign in to comment.