Code Monkey home page Code Monkey logo

learn-1's Introduction

所有配置文件都是从配置中心获取:
配置文件:learn-cloud-config--->cloud-config-repo-->cloud-config-dev.properties
修改后提交git后才能生效

公用组件
learn-cloud-common 获取配置中心配置文件,除learn-cloud-config所有的learn-cloud-* 都要依赖
learn-shop-base-common 依赖learn-cloud-common,所有的learn-shop-admin-* 和learn-shop-core-* 都要依赖
learn-shop-base-pojo po和vo以及ex,所有的learn-shop-admin-* 和learn-shop-core-* 都要依赖
learn-shop-base-tools 公用工具

核心服务,端口:87**:
learn-cloud-eureka 注册中心,端口:8761
learn-cloud-zuul 路由网关,端口:8771
learn-cloud-config 分布式配置中心,端口:8781
learn-cloud-turbine 熔断器控制聚合,端口:8791
learn-cloud-zipkin 追踪服务,端口:8751

公用业务服务,端口:80**:
learn-shop-public-job 自动任务,端口:8011
learn-shop-public-tx 分布式事务管理中心,端口:8021

后端业务服务,端口:88**:
learn-shop-admin-user 用户管理服务,端口:8801
learn-shop-admin-system 系统管理服务,端口:

前台业务服务,端口:89**:
learn-shop-core-order 购物车服务,端口:8901
learn-shop-core-cart 购物车服务,端口:
learn-shop-core-product 购物车服务,端口:

项目启动顺序:

  • learn-cloud-config
  • learn-cloud-eureka
  • learn-cloud-zuul 可选
  • learn-cloud-turbine 可选
  • learn-shop-public-tx 事务管理中心服务(tx-lcn)
  • 启动公用业务服务
  • 启动业务服务

访问:(通过路由)
注册中心:
http://localhost:8761/eureka

业务服务:
http://localhost:8771/core-order #订单相关
http://localhost:8771/admin-user #用户相关

熔断器:
访问:http://localhost:/hystrix
输入:http://localhost:/hystrix.stream

熔断器聚合:
访问:http://http://localhost:8791/hystrix
输入:http://localhost:/hystrix.stream

RabbitMQ: 管理页面
http://localhost:15672

Druid: 管理页面
http://localhost:/druid

Swagger2: 管理页面
http://localhost:/swagger-ui.html(查看单个)
http://localhost:8771/swagger-ui.html(查看聚合)
或者进入注册中心点击实例链接直接查看

LCN: 分布式事务管理中心页面
http://localhost:/index.html
或者进入注册中心点击实例链接直接查看

注意:
0.特别提醒:如果使用本地配置文件需要修改learn-cloud-config下的resources里面的application.yml的search-locations修改为本地路径
1.添加新服务时,要在learn-cloud-zuul中添加路由表
 core-order:
    path: /core-order/**
    serviceId: learn-shop-core-order

2.使用配置中心时,
配置中心启动时会向注册中心注册,这里注册中心还没启动会报异常,不用关心
如果是learn-cloud-* pom中添加learn-cloud-common依赖
如果是learn-shop-admin-* 和learn-shop-core-* pom中添加learn-shop-base-common依赖

3.项目启动先要条件
3.1 RabbitMQ, rabbitmq-server.bat
添加新用户:admin 密码:admin123,修改admin用为超级管理员
查询所有用户:rabbitmqctl.bat list_users
添加新用户: rabbitmqctl.bat add_user username password
赋予用户权限:rabbitmqctl.bat set_user_tags username administrator
在admin中设定虚拟主机(virtual-host)为/learn-default
3.2 redis启动

4.swagger2注解使用说明:
https://www.jianshu.com/p/12f4394462d5

5.本系统事务依赖tx-lcn,(https://github.com/codingapi/tx-lcn) ,
示例代码查看 https://github.com/codingapi/springcloud-lcn-demo
示例使用说明 https://github.com/codingapi/springcloud-lcn-demo/wiki
TxClient使用说明:https://github.com/codingapi/tx-lcn/wiki/TxClient%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E
启动运行TxManagerApplication, 然后访问 http://127.0.0.1:8899/index.html

5.1 使用时添加

    <dependency>
        <groupId>com.codingapi</groupId>
        <artifactId>transaction-springcloud</artifactId>
    </dependency>
    <dependency>
        <groupId>com.codingapi</groupId>
        <artifactId>tx-plugins-db</artifactId>
    </dependency>

5.2 配置tx-manager的url地址。有两种方式
方式一: 使用默认方式是添加tx.properties文件,内容如下

url=http://127.0.0.1:8899/tx/manager/

方式二: 自定义url的配置.

1.编写配置文件到application.properties文件下key tm.manager.url如:
tm.manager.url=http://127.0.0.1:8899/tx/manager/。

2.复写读取配置文件的类TxManagerTxUrlService。

import com.codingapi.tx.config.service.TxManagerTxUrlService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

@Service
public class TxManagerTxUrlServiceImpl implements TxManagerTxUrlService{

@Value("${tm.manager.url}")
private String url;

@Override
public String getTxUrl() {
    System.out.println("load tm.manager.url ");
    return url;
}

}

如何将tx-manager的访问地址设置为服务发现的方式.
复写TxManagerHttpRequestService自定义方法方式.

import com.codingapi.tx.netty.service.TxManagerHttpRequestService;
import com.lorne.core.framework.utils.http.HttpUtils;
import org.springframework.stereotype.Service;

@Service
public class TxManagerHttpRequestServiceImpl implements TxManagerHttpRequestService{

@Override
public String httpGet(String url) {
    System.out.println("httpGet-start");
    String res = HttpUtils.get(url);
    System.out.println("httpGet-end");
    return res;
}

@Override
public String httpPost(String url, String params) {
    System.out.println("httpPost-start");
    String res = HttpUtils.post(url,params);
    System.out.println("httpPost-end");
    return res;
}

}


HTTP Method 与 CURD 数据处理操作对应

POST Create 新增一个没有id的资源

GET Read 取得一个资源

PUT Update 更新一个资源。或新增一个含 id 资源(如果 id 不存在)

DELETE Delete 删除一个资源

learn-1's People

Contributors

xiao-y avatar dependabot[bot] avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.