ylbtech-架构-Eureka:第一个方法

工程介绍

Spring Cloud

工程目录

  • model
  • registry-center
  • Servers
  • tzxyfx
  • tzxyfx-provider
  • zinpkin

启动流程

1.运行注册中心

运行工程方式如下:RunAs-->Java Application|(Alt+Shift+X,R)

2.运行客户端

3.运行服务端

4.

1. model返回顶部
 
2. registry-center返回顶部
 
3. Servers返回顶部
 
4. tzxyfx返回顶部
1、src/mian/java
1.1 com.tzxyfx
1.1.1 sbtz
controller
package com.tzxyfx.sbtz.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import com.tzxyfx.common.util.user.UserInfoUtil;
import com.tzxyfx.sbtz.entity.Sbtz;
import com.tzxyfx.sbtz.service.SbtzService; /**
* @Description 内容控制器
* @author gjx
* @version v1.0
*/
@Controller
@RequestMapping("/sbtz")
public class SbtzController { @Resource
private SbtzService sbtzService; /**
* 前沿咨询请求
*
* @param model
* @return
*/
@RequestMapping("/searchSbtz")
public String searchSbtz(Sbtz sbtz) { sbtz.setArticleId("aaa");
List<Sbtz> sbtzList = sbtzService.searchSbtz(sbtz);
System.out.println("======SbtzController_end=====" + sbtzList.size()); UserInfoUtil.getRequest().setAttribute("lxjs", sbtzList); System.out.println("======SbtzController_end====="); return "forward:/sbtz.html";
} }
entity
package com.tzxyfx.sbtz.entity;

/**
*
* @Description
* @author gjx
* @date 2018年8月28日 下午2:32:36
* @version v1.0
*/
public class Sbtz {
private String articleId; private String articleTitle; public String getArticleId() {
return articleId;
} public void setArticleId(String articleId) {
this.articleId = articleId == null ? null : articleId.trim();
} public String getArticleTitle() {
return articleTitle;
} public void setArticleTitle(String articleTitle) {
this.articleTitle = articleTitle == null ? null : articleTitle.trim();
} }
service
package com.tzxyfx.sbtz.service;

import java.util.List;

import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping; import com.tzxyfx.common.config.mvc.FullLogConfiguration;
import com.tzxyfx.sbtz.entity.Sbtz; @FeignClient(value = "TZXYFX-PROVIDER", configuration = FullLogConfiguration.class, path = "/sbtz")
public interface SbtzService { /**
*
* @param
* @param
* @return
*/
@RequestMapping(value = "/searchSbtz")
List<Sbtz> searchSbtz(Sbtz sbtz); }
关联服务端代码 @FeignClient(value = "TZXYFX-PROVIDER", configuration = FullLogConfiguration.class, path = "/sbtz") 
 
2、src/main/resources
2.1 mybatis
2.2 application-dev.properties
2.2 application.properties
 
3、src/main/webapp
3.1 css
3.2 images
3.3 js
3.4
-home.html  主页
-sbtz.html  设备台帐分析
-xmtz.html  电网诊断与评价
-zhjh.html  综合计划项目管控
 
4、
-src
--main
---java
----com.tzxyfx
-----common
-----sbtz
------controller
-------SbtzController.java
package com.tzxyfx.sbtz.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import com.tzxyfx.common.util.user.UserInfoUtil;
import com.tzxyfx.sbtz.entity.Sbtz;
import com.tzxyfx.sbtz.service.SbtzService; /**
* @Description 内容控制器
* @author gjx
* @version v1.0
*/
@Controller
@RequestMapping("/sbtz")
public class SbtzController { @Resource
private SbtzService sbtzService; /**
* 前沿咨询请求
*
* @param model
* @return
*/
@RequestMapping("/searchSbtz")
public String searchSbtz(Sbtz sbtz) { sbtz.setArticleId("aaa");
List<Sbtz> sbtzList = sbtzService.searchSbtz(sbtz);
System.out.println("======SbtzController_end=====" + sbtzList.size()); UserInfoUtil.getRequest().setAttribute("lxjs", sbtzList); System.out.println("======SbtzController_end====="); return "forward:/sbtz.html";
} }
------entity
package com.tzxyfx.sbtz.entity;

/**
*
* @Description
* @author gjx
* @date 2018年8月28日 下午2:32:36
* @version v1.0
*/
public class Sbtz {
private String articleId; private String articleTitle; public String getArticleId() {
return articleId;
} public void setArticleId(String articleId) {
this.articleId = articleId == null ? null : articleId.trim();
} public String getArticleTitle() {
return articleTitle;
} public void setArticleTitle(String articleTitle) {
this.articleTitle = articleTitle == null ? null : articleTitle.trim();
} }
------service
package com.tzxyfx.sbtz.service;

import java.util.List;

import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping; import com.tzxyfx.common.config.mvc.FullLogConfiguration;
import com.tzxyfx.sbtz.entity.Sbtz; @FeignClient(value = "TZXYFX-PROVIDER", configuration = FullLogConfiguration.class, path = "/sbtz")
public interface SbtzService { /**
*
* @param
* @param
* @return
*/
@RequestMapping(value = "/searchSbtz")
List<Sbtz> searchSbtz(Sbtz sbtz); }
-----sys
-----TzxyfxApplication.java
package com.tzxyfx;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.context.annotation.Bean; import com.base.util.redis.RedisCache; @SpringBootApplication
@EnableFeignClients
@EnableDiscoveryClient public class TzxyfxApplication { public static void main(String[] args) {
SpringApplication.run(TzxyfxApplication.class, args);
} @Bean
public RedisCache redisCache(){
return new RedisCache();
} }
----com
---resoureces
---mybatis
----mapper
-----mybatis_trainingNeeds.xml
-----mybatis_user.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tzxyfx.sys.dao.UserDao"> <resultMap type="com.tzxyfx.sys.entity.User" id="userLoginMap">
<id property="userId" column="USER_ID"/>
<result property="loginName" column="LOGIN_NAME"/>
<result property="userName" column="NAME"/>
<result property="state" column="STATE"/>
<result property="orgId" column="ORG_ID"/>
<result property="password" column="PASSWORD"/> <result property="identityNo" column="IDENTITY_NO"/>
<result property="mobile" column="MOBILE"/>
<result property="email" column="EMAIL"/>
<result property="officePhone" column="OFFICE_PHONE"/>
<result property="type" column="TYPE"/>
<result property="updateDate" column="UPDATE_DATE"/>
<result property="orderNo" column="ORDER_NO"/>
<!-- 需要添加Connction 角色信息 -->
<collection property="roles" ofType="com.base.entity.Role" javaType="java.util.ArrayList">
<result column="ROLE_ID" property="roleId" jdbcType="VARCHAR" />
<result column="SYSTEM_ID" property="systemId" jdbcType="VARCHAR" />
<result column="ROLE_NAME" property="roleName" jdbcType="VARCHAR" />
</collection>
</resultMap> <!-- 根据账号来获取用户信息 -->
<select id="findByLogin" parameterType="java.lang.String" resultMap="userLoginMap">
select u.*,r.role_id as role_id,r.role_name as role_name from t_user u inner join t_user_role ur on u.user_id = ur.user_id inner join t_role r on r.role_id = ur.role_id where u.login_name = #{login}
</select> </mapper>
----mybatis-config.xml
---application-dev.properties
---application.properties
---webapp
--test
5、
6、
5. tzxyfx-provider返回顶部
1、
src
-main
--java
---com.tzxyfx
----common.config
----sbtz
-----conf
------controller
-------SbtzController.java
package com.tzxyfx.sbtz.controller;

import java.util.List;

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.RestController; import com.tzxyfx.sbtz.entity.Sbtz;
import com.tzxyfx.sbtz.service.SbtzService; /*
* 类描述: role 的controller 层
* @auther wangmx
*/
@RestController
@RequestMapping("/sbtz")
public class SbtzController { @Autowired
private SbtzService sbtzService; @RequestMapping(value = "/searchSbtz")
public List<Sbtz> searchSbtz(@RequestBody Sbtz sbtz){ List<Sbtz> sbtzList = sbtzService.searchSbtz(sbtz); return sbtzList;
} }
------dao
-------SbtzDao.java
package com.tzxyfx.sbtz.dao;

import java.util.List;

import com.tzxyfx.sbtz.entity.Sbtz;

/**
* @author lc
**/
public interface SbtzDao { /**
* 关联 查询
*
* @param entity
* 查询 条件
*/
List<Sbtz> searchSbtz(String sbtz);
}
------entity
-------Sbtz.java
package com.tzxyfx.sbtz.entity;

/**
*
* @Description
* @author gjx
* @date 2018年8月28日 下午2:32:36
* @version v1.0
*/
public class Sbtz {
private String articleId; private String articleTitle; private String userId; private String loginName; public String getArticleId() {
return articleId;
} public void setArticleId(String articleId) {
this.articleId = articleId == null ? null : articleId.trim();
} public String getArticleTitle() {
return articleTitle;
} public void setArticleTitle(String articleTitle) {
this.articleTitle = articleTitle == null ? null : articleTitle.trim();
} public String getUserId() {
return userId;
} public void setUserId(String userId) {
this.userId = userId;
} public String getLoginName() {
return loginName;
} public void setLoginName(String loginName) {
this.loginName = loginName;
} }
------service
-------imp
--------SbtzServiceImpl.java
package com.tzxyfx.sbtz.service.imp;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import com.tzxyfx.sbtz.dao.SbtzDao;
import com.tzxyfx.sbtz.entity.Sbtz;
import com.tzxyfx.sbtz.service.SbtzService; /**
* @author lc
**/
@Service
@Transactional
public class SbtzServiceImpl implements SbtzService{
@Autowired
private SbtzDao sbtzDao; @Override
public List<Sbtz> searchSbtz(Sbtz sbtz) {
List<Sbtz> lis = null;
try { lis = sbtzDao.searchSbtz(sbtz.getArticleId()); } catch (Exception e) {
e.printStackTrace();
// TODO: handle exception
}
return lis;
} }
-------SbtzService.java
package com.tzxyfx.sbtz.service;

import java.util.List;

import com.tzxyfx.sbtz.entity.Sbtz;

/**
* @author lc
**/
public interface SbtzService { /**
* 功能描述:加载用户的菜单树的数据
*
* @param user
* @return
*/
public List<Sbtz> searchSbtz(Sbtz sbtz); }
----sys
----TzxyfxPApplication.java
package com.tzxyfx;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.context.annotation.Bean; import com.base.util.redis.RedisCache; @SpringBootApplication
public class TzxyfxPApplication { public static void main(String[] args) {
SpringApplication.run(TzxyfxPApplication.class, args);
} /**
* 功能描述:注入redis
* @return
*/
@Bean
public RedisCache redisCache(){
return new RedisCache();
}
}
---com
----com.tzxyfx
--resources
---mybatis
----mapper
-----mybais_SbtzMapper.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tzxyfx.sbtz.dao.SbtzDao"> <resultMap type="com.tzxyfx.sbtz.entity.Sbtz" id="SbtzMap">
<id property="userId" column="USER_ID"/>
<result property="loginName" column="LOGIN_NAME"/>
</resultMap> <!-- 查询 + -->
<select id="searchSbtz" resultMap="SbtzMap">
select * from t_user where name like '赵云%'
</select> </mapper>
-----mybatis-config.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<typeAliases>
<typeAlias alias="Integer" type="java.lang.Integer" />
<typeAlias alias="Long" type="java.lang.Long" />
<typeAlias alias="HashMap" type="java.util.HashMap" />
<typeAlias alias="LinkedHashMap" type="java.util.LinkedHashMap" />
<typeAlias alias="ArrayList" type="java.util.ArrayList" />
<typeAlias alias="LinkedList" type="java.util.LinkedList" />
</typeAliases>
</configuration>
----application-dev.properties
----application.properties
-test
 
2、
3、
4、
5、
6、
 
6. zinpkin 返回顶部
 
作者:ylbtech
出处:http://ylbtech.cnblogs.com/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

架构-Eureka:第一个方法的更多相关文章

  1. ABSD 基于架构的软件设计方法方法简介(摘抄)

    ABSD(Architecture-Based Software Design)基于架构的软件设计方法 有三个基础: 第一个基础是功能分解.在功能分解中,ABSD方法使用已有的基于模块的内聚和耦合技术 ...

  2. springCloud进阶(微服务架构&Eureka)

    springCloud进阶(微服务架构&Eureka) 1. 微服务集群 1.1 为什么要集群 为了提供并发量,有时同一个服务提供者可以部署多个(商品服务).这个客户端在调用时要根据一定的负责 ...

  3. [moka同学笔记]yii2.0小物件的简单使用(第一种方法)

    这是第一种方法,还有另一种方法,其实都差不多. 1.在创建widgets\HelloWiget.php <?php /** * Created by PhpStorm. * User: Admi ...

  4. iOS 清理缓存功能实现第一种方法

    添加一个提示框效果导入第三方MBProgressHUD #import "MBProgressHUD+MJ.h" /** * 清理缓存第一种方法 */ -(void)clearCa ...

  5. Qt5.9一个简单的多线程实例(类QThread)(第一种方法)

    Qt开启多线程,主要用到类QThread.有两种方法,第一种用一个类继承QThread,然后重新改写虚函数run().当要开启新线程时,只需要实例该类,然后调用函数start(),就可以开启一条多线程 ...

  6. Eureka错误解决方法

    # Eureka错误解决方法 ## security.basic.enabled 配置过时或不可用默认情况下:用户名:user密码:启动应用在控制台会输出,如下图: 也可以通过如下属性配置:sprin ...

  7. ActiveMQ源码架构解析第一节(转)

    工作四年已久,也快到了而立之年,本人也酷爱技术,总是想找一些途径来提升自己,想着温故而知新所以就写起了博客,然而写博客这个想法也是酝酿了很久,近期也看到了有很多人在问关于ActiveMQ的相关问题,有 ...

  8. 搭建一个BS 的简单SOA 架构(直接通过jquery 调用后台的 wcf 服务的架构)(第一天)

    亲们!还在用传统的三层架构吗?你还在对SOA架构 不了解吗? 那就赶快来学习下一个 比较简单的SOA的架构吧!我会手把手的 教会你们怎么搭建这个 简单的SOA的架构. 其中用的技术点保证  WCF,a ...

  9. 常见架构TLB miss处理方法(转)

    转自网站:http://blog.sina.com.cn/s/blog_633f462901018reb.html 0.       综述 总的来说TLB miss处理分为硬件处理和软件处理两种,硬件 ...

随机推荐

  1. P1796 汤姆斯的天堂梦_NOI导刊2010提高(05)

    题目描述 汤姆斯生活在一个等级为0的星球上.那里的环境极其恶劣,每天12小时的工作和成堆的垃圾让人忍无可忍.他向往着等级为N的星球上天堂般的生活. 有一些航班将人从低等级的星球送上高一级的星球,有时需 ...

  2. webSphere

    WebSphere 是 IBM 的软件平台.它包含了编写.运行和监视全天候的工业强度的随需应变 Web 应用程序和跨平台.跨产品解决方案所需要的整个中间件基础设施,如服务器.服务和工具.WebSphe ...

  3. Polymorphism (computer science)

    In programming languages and type theory, polymorphism (from Greek πολύς, polys, "many, much&qu ...

  4. antd #upload

    import React from 'react' import {Upload, Icon, message,Button } from 'antd' import './index.scss'; ...

  5. 【转载自JHBlogs的博客】postman接口自动化,环境变量的用法详解(附postman常用的方法)

    在实现接口自动测试的时候,会经常遇到接口参数依赖的问题,例如调取登录接口的时候,需要先获取登录的key值,而每次请求返回的key值又是不一样的,那么这种情况下,要实现接口的自动化,就要用到postma ...

  6. Spring实战(中文4,5版) PDF含源码

    Spring实战 读者评价 看了一半后在做评论,物流速度挺快,正版行货,只是运输过程有点印记,但是想必大家和你关注内容,spring 4必之3更加关注的是使用注解做开发,对于初学者还是很有用,但是不排 ...

  7. 【剑指Offer】8、跳台阶

      题目描述:   一只青蛙一次可以跳上1级台阶,也可以跳上2级.求该青蛙跳上一个n级的台阶总共有多少种跳法(先后次序不同算不同的结果).   解题思路:   首先考虑最简单的情况,如果只有1级台阶, ...

  8. 数据挖掘系列 (1) 关联规则挖掘基本概念与 Aprior 算法

    转自:http://www.cnblogs.com/fengfenggirl/p/associate_apriori.html 数据挖掘系列 (1) 关联规则挖掘基本概念与 Aprior 算法 我计划 ...

  9. 配置zabbix及安装agent

    一.配置zabbix http://ip/zabbix/setup.php Next step Next step 输入数据库密码后,Next step Next step 默认用户名是Admin 密 ...

  10. 基于Mysql-Proxy 实现MariaDB 读写分离

    一.Mysql-Proxy 简单介绍 MySQL-Proxy是一个处于你的client端和MySQL server端之间的简单程序,它可以监测.分析或改变它们的通信.它使用灵活,没有限制,常见的用途包 ...