------------------------------------------------------------------------------------------------------------
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 org.apache.maven.plugins maven-surefire-plugin false
捐助开发者
在兴趣的驱动下,写一个免费
的东西,有欣喜,也还有汗水,希望你喜欢我的作品,同时也能支持一下。 当然,有钱捧个钱场(右上角的爱心标志,支持支付宝和PayPal捐助),没钱捧个人场,谢谢各位。