博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
springcloud 服务提供方 compute-service
阅读量:6224 次
发布时间:2019-06-21

本文共 7154 字,大约阅读时间需要 23 分钟。

 

 

 ------------------------------------------------------------------------------------------------------------ 

     

   

 

  

  

 

t   

 

 

 ------------------------------------------------------------------------------------------------------------ 

 

@EnableDiscoveryClient@SpringBootApplication  public class SpringBootSampleApplication {                 public static void main(String[] args) {        SpringApplication.run(SpringBootSampleApplication.class, args);    }}

 

@RestControllerpublic class UserService {     private final Logger logger = Logger.getLogger(UserService.class);    @Resource    UserDao userDao;        @Autowired    private DiscoveryClient client;        @RequestMapping(value = "/user/{userId}" ,method = RequestMethod.GET)    public User  findById(@PathVariable(value = "userId") int userId){        ServiceInstance instance = client.getLocalServiceInstance();        logger.info("/add, host:" + instance.getHost() + ", service_id:" + instance.getServiceId() + ", result:"  );                System.out.println("================productor===================");         User user = userDao.findById(userId);        System.out.println("================productor==================="+user);        return user;    }}

 

package com.curiousby.cn.entity;import java.io.Serializable;import javax.persistence.Column;import javax.persistence.Entity;import javax.persistence.Id;import javax.persistence.Table;/** * @Type User.java * @Desc  * @author cmcc-B100036 * @date 2016年11月10日 下午3:44:08 * @version  */@Entity@Table(name = "t_user")public class User implements Serializable{        /**     *      */    private static final long serialVersionUID = 1381806832842693234L;        @Id    private int id;    @Column(name = "user_name")    private String userName;        @Column(name = "password")    private String password;        @Column(name = "tel")    private String tel;        @Column(name = "sex")    private String sex;         @Column(name = "description")    private String description;            public int getId() {        return id;    }    public String getUserName() {        return userName;    }    public String getPassword() {        return password;    }    public String getTel() {        return tel;    }    public String getSex() {        return sex;    }    public String getDescription() {        return description;    }    public void setId(int id) {        this.id = id;    }    public void setUserName(String userName) {        this.userName = userName;    }    public void setPassword(String password) {        this.password = password;    }    public void setTel(String tel) {        this.tel = tel;    }    public void setSex(String sex) {        this.sex = sex;    }    public void setDescription(String description) {        this.description = description;    }                }

 

package com.curiousby.cn.dao;import javax.transaction.Transactional;import org.springframework.data.repository.CrudRepository;import com.curiousby.cn.entity.User; /** * @Type UserDao.java * @Desc  * @author cmcc-B100036 * @date 2016年11月10日 下午3:49:04 * @version  */@Transactionalpublic interface  UserDao extends CrudRepository
{ //crud User findById(int id);}

 

 

spring.mvc.view.prefix=/WEB-INF/jsp/spring.mvc.view.suffix=.jspspring.application.name=compute-serviceserver.port=1001server.session-timeout=60# server.address=192.168.16.11 #one datasourcespring.datasource.url=jdbc:mysql://localhost:3306/databasespring.datasource.username=rootspring.datasource.password=rootspring.datasource.driverClassName=com.mysql.jdbc.Drivereureka.client.serviceUrl.defaultZone=http://localhost:1000/eureka/

 

 

4.0.0
com.curiousby.cn
SpringCloudDemo-Feign
war
0.0.1-SNAPSHOT
SpringCloudDemo-Feign Maven Webapp
http://maven.apache.org
spring-snapshots
http://repo.spring.io/libs-snapshot
spring-snapshots
http://repo.spring.io/libs-snapshot
org.springframework.boot
spring-boot-starter-parent
1.3.5.RELEASE
UTF-8
1.7
org.springframework.cloud
spring-cloud-starter-hystrix
org.springframework.cloud
spring-cloud-starter-feign
org.springframework.cloud
spring-cloud-starter-eureka
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter-tomcat
provided
org.apache.tomcat.embed
tomcat-embed-jasper
provided
javax.servlet
jstl
org.springframework.boot
spring-boot-starter-test
test
org.springframework.boot
spring-boot-starter-data-jpa
runtime
mysql
mysql-connector-java
runtime
org.springframework.cloud
spring-cloud-dependencies
Brixton.RELEASE
pom
import
SpringCloudDemo-Feign
org.springframework.boot
spring-boot-maven-plugin
org.apache.maven.plugins
maven-compiler-plugin
1.7
1.7
org.apache.maven.plugins
maven-surefire-plugin
false

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

捐助开发者

在兴趣的驱动下,写一个免费的东西,有欣喜,也还有汗水,希望你喜欢我的作品,同时也能支持一下。 当然,有钱捧个钱场(右上角的爱心标志,支持支付宝和PayPal捐助),没钱捧个人场,谢谢各位。

 
 
 谢谢您的赞助,我会做的更好!

 

 

转载地址:http://hkfna.baihongyu.com/

你可能感兴趣的文章
创建3层的服务模板 (2)--- App-V package 和 Application Profile
查看>>
基于java.nio.channels的编程实践-I
查看>>
多线程同步基础
查看>>
学习Nagios(一):Nagios安装
查看>>
@RequestParam 的用法
查看>>
修改CentOS菜单
查看>>
消息队列
查看>>
iOS开发UI篇—无限轮播(循环展示)
查看>>
iOS集成支付宝
查看>>
全栈工程师体能备战--阅读的书籍
查看>>
用UIInterpolatingMotionEffect产生透视效果
查看>>
Redis笔记(八)Redis的持久化
查看>>
【DATAGUARD】Data Guard Wait Events
查看>>
(九十七)函数与array对象
查看>>
android 内部文件读取
查看>>
Python 对图片进行人脸识别
查看>>
Go语言简明教程
查看>>
JVM Class字节码之三-使用BCEL改变类属性
查看>>
[JAVA · 初级]:9.Object类提供的常用方法
查看>>
2016年2月问答活跃达人发奖品喽,大家快来领奖!
查看>>