Commit 2775a7d5 authored by fangxinjiang's avatar fangxinjiang

init

parent 6f43d9c5
......@@ -14,26 +14,6 @@ management:
health:
show-details: ALWAYS
# feign 配置
feign:
sentinel:
enabled: true
okhttp:
enabled: true
httpclient:
enabled: false
client:
config:
default:
connectTimeout: 10000
readTimeout: 10000
compression:
request:
enabled: true
response:
enabled: true
# mybaits-plus配置
mybatis-plus:
mapper-locations: classpath:/mapper/*Mapper.xml
......@@ -50,6 +30,10 @@ mybatis-plus:
# spring security 配置
security:
oauth2:
client:
client-id: ENC(27v1agvAug87ANOVnbKdsw==)
client-secret: ENC(VbnkopxrwgbFVKp+UxJ2pg==)
scope: server
resource:
loadBalanced: true
token-info-uri: http://yifu-auth/oauth/check_token
......@@ -59,15 +43,7 @@ security:
- /v3/api-docs
- /actuator/**
# swagger 配置
swagger:
enabled: true
title: Yifu Swagger API
gateway: http://${GATEWAY_HOST:yifu-gateway}:${GATEWAY-PORT:9999}
token-url: ${swagger.gateway}/auth/oauth/token
services:
yifu-upms-biz: admin
yifu-codegen: gen
# Spring 相关
spring:
application:
......
......@@ -22,16 +22,16 @@
<artifactId>yifu-common-core</artifactId>
</dependency>
<!--swagger 注解-->
<dependency>
<!--<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId>
</dependency>
</dependency>-->
<!--feign 注解依赖-->
<dependency>
<!--<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-openfeign-core</artifactId>
<optional>true</optional>
</dependency>
</dependency>-->
<!--mybatis 依赖-->
<dependency>
<groupId>com.yifu.cloud.plus.v1</groupId>
......
package com.yifu.cloud.plus.v1.yifu.consumer.feign;
\ No newline at end of file
......@@ -43,30 +43,30 @@
<artifactId>yifu-common-security</artifactId>
</dependency>
<!--必备:服务处理-->
<dependency>
<!--<dependency>
<groupId>com.yifu.cloud.plus.v1</groupId>
<artifactId>yifu-common-feign</artifactId>
</dependency>
</dependency>-->
<!--必备:日志处理-->
<dependency>
<groupId>com.yifu.cloud.plus.v1</groupId>
<artifactId>yifu-common-log</artifactId>
</dependency>
<!--必备:swagger-->
<dependency>
<!--<dependency>
<groupId>com.yifu.cloud.plus.v1</groupId>
<artifactId>yifu-common-swagger</artifactId>
</dependency>
</dependency>-->
<!--必备: 注册中心客户端-->
<dependency>
<!-- <dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
</dependency>-->
<!--必备: 配置中心客户端-->
<dependency>
<!--<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
</dependency>-->
<!--必备:undertow容器-->
<dependency>
<groupId>org.springframework.boot</groupId>
......
package com.yifu.cloud.plus.v1.consumer;
import com.yifu.cloud.plus.v1.yifu.common.feign.annotation.EnableYifuFeignClients;
import com.yifu.cloud.plus.v1.yifu.common.security.annotation.EnableYifuResourceServer;
import com.yifu.cloud.plus.v1.yifu.common.swagger.annotation.EnableYifuDoc;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
/**
* @author pig archetype
* <p>
* 项目启动类
*/
@EnableYifuDoc
@EnableYifuFeignClients
@EnableYifuResourceServer
@EnableDiscoveryClient
@SpringBootApplication
public class ConsumerApplication {
......
......@@ -21,8 +21,6 @@ import com.yifu.cloud.plus.v1.consumer.entity.Consumer;
import com.yifu.cloud.plus.v1.consumer.mapper.ConsumerMapper;
import com.yifu.cloud.plus.v1.consumer.service.ConsumerService;
import com.yifu.cloud.plus.v1.provider.entity.Provider;
import com.yifu.cloud.plus.v1.provider.feign.RemoteProviderService;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.SecurityConstants;
import io.seata.spring.annotation.GlobalTransactional;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
......@@ -38,7 +36,6 @@ import org.springframework.transaction.annotation.Transactional;
@Service
public class ConsumerServiceImpl extends ServiceImpl<ConsumerMapper, Consumer> implements ConsumerService {
private final RemoteProviderService remoteProviderService;
@GlobalTransactional // 分布式seata事务
......@@ -52,7 +49,7 @@ public class ConsumerServiceImpl extends ServiceImpl<ConsumerMapper, Consumer> i
provider.setCreateTime(consumer.getCreateTime());
provider.setUpdateBy(consumer.getUpdateBy());
provider.setUpdateTime(consumer.getUpdateTime());
remoteProviderService.testSeata(provider, SecurityConstants.FROM_IN);
//remoteProviderService.testSeata(provider, SecurityConstants.FROM_IN);
baseMapper.insert(consumer);
return true;
}
......
server:
port: 7002
# 加解密根密码
jasypt:
encryptor:
password: pig #根密码
# 暴露监控端点
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: ALWAYS
## spring security 配置
security:
oauth2:
client:
client-id: ENC(27v1agvAug87ANOVnbKdsw==)
client-secret: ENC(VbnkopxrwgbFVKp+UxJ2pg==)
scope: server
resource:
loadBalanced: true
token-info-uri: http://yifu-auth/oauth/check_token
# mybaits-plus配置
mybatis-plus:
mapper-locations: classpath:/mapper/*Mapper.xml
global-config:
banner: false
db-config:
id-type: auto
table-underline: true
logic-delete-value: 1
logic-not-delete-value: 0
configuration:
map-underscore-to-camel-case: true
# 直接放行URL
ignore:
urls:
- /v2/api-docs
- /actuator/**
spring:
application:
name: @artifactId@
cloud:
nacos:
discovery:
server-addr: ${NACOS_HOST:yifu-register}:${NACOS_PORT:8848}
---
# 数据源配置
spring:
redis:
host: yifu-redis
password: '@yf_2017'
datasource:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
username: root
password: yf_zsk
url: jdbc:mysql://192.168.1.65:22306/consumer?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
config:
server-addr: ${spring.cloud.nacos.discovery.server-addr}
activate:
on-profile: test
---
# 数据源配置
spring:
redis:
host: yifu-redis
password: '@yf_2017'
datasource:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
username: root
password: yf_zsk
url: jdbc:mysql://192.168.1.65:22306/consumer?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
config:
import:
- nacos:application-@profiles.active@.yml
- nacos:${spring.application.name}-@profiles.active@.yml
activate:
on-profile: dev
......@@ -2,9 +2,7 @@ package com.yifu.cloud.plus.v1.provider.feign;
import com.yifu.cloud.plus.v1.provider.entity.Provider;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.SecurityConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ServiceNameConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
......@@ -13,7 +11,7 @@ import org.springframework.web.bind.annotation.RequestHeader;
* @author fxj
* @Date 2022-05-14
*/
@FeignClient(contextId="remoteProviderService",value = ServiceNameConstants.PROVIDER_SERVICE)
//@FeignClient(contextId="remoteProviderService",value = ServiceNameConstants.PROVIDER_SERVICE)
public interface RemoteProviderService {
@PostMapping("/provider/inner/save")
R<Boolean> testSeata(@RequestBody Provider provider, @RequestHeader(SecurityConstants.FROM) String from);
......
package com.yifu.cloud.plus.v1.provider.feign.factory;
import com.yifu.cloud.plus.v1.provider.feign.RemoteProviderService;
import com.yifu.cloud.plus.v1.provider.feign.fallback.RemoteProviderServiceFallbackImpl;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
//异常回调工厂
@Component
public class RemoteProviderServiceFallbackFactory implements FallbackFactory<RemoteProviderService> {
@Override
public RemoteProviderService create(Throwable cause) {
RemoteProviderServiceFallbackImpl remoteProviderServiceFallback = new RemoteProviderServiceFallbackImpl();
remoteProviderServiceFallback.setCause(cause);
return remoteProviderServiceFallback;
}
}
package com.yifu.cloud.plus.v1.provider.feign.fallback;
import com.yifu.cloud.plus.v1.provider.entity.Provider;
import com.yifu.cloud.plus.v1.provider.feign.RemoteProviderService;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import lombok.Setter;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Component;
@Log4j2
@Component
public class RemoteProviderServiceFallbackImpl implements RemoteProviderService {
@Setter
private Throwable cause;
@Override
public R<Boolean> testSeata(Provider provider, String from) {
log.error("测试seata异常",provider,cause);
return null;
}
}
package com.yifu.cloud.plus.v1.provider.feign;
\ No newline at end of file
......@@ -43,30 +43,30 @@
<artifactId>yifu-common-security</artifactId>
</dependency>
<!--必备:服务处理-->
<dependency>
<!--<dependency>
<groupId>com.yifu.cloud.plus.v1</groupId>
<artifactId>yifu-common-feign</artifactId>
</dependency>
</dependency>-->
<!--必备:日志处理-->
<dependency>
<groupId>com.yifu.cloud.plus.v1</groupId>
<artifactId>yifu-common-log</artifactId>
</dependency>
<!--必备:swagger-->
<dependency>
<!--<dependency>
<groupId>com.yifu.cloud.plus.v1</groupId>
<artifactId>yifu-common-swagger</artifactId>
</dependency>
</dependency>-->
<!--必备: 注册中心客户端-->
<dependency>
<!--<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
</dependency>-->
<!--必备: 配置中心客户端-->
<dependency>
<!--<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
</dependency>-->
<!--必备:undertow容器-->
<dependency>
<groupId>org.springframework.boot</groupId>
......
package com.yifu.cloud.plus.v1.provider;
import com.yifu.cloud.plus.v1.yifu.common.feign.annotation.EnableYifuFeignClients;
import com.yifu.cloud.plus.v1.yifu.common.security.annotation.EnableYifuResourceServer;
import com.yifu.cloud.plus.v1.yifu.common.swagger.annotation.EnableYifuDoc;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.ComponentScan;
/**
* @author pig archetype
* <p>
* 项目启动类
*/
@EnableYifuDoc
@EnableYifuFeignClients
@EnableYifuResourceServer
@EnableDiscoveryClient
//@ComponentScan(basePackages = {"com.yifu.cloud.plus.v1"})
@SpringBootApplication
public class ProviderApplication {
......
server:
port: 7001
# 加解密根密码
jasypt:
encryptor:
password: pig #根密码
# 暴露监控端点
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: ALWAYS
security:
oauth2:
client:
client-id: ENC(27v1agvAug87ANOVnbKdsw==)
client-secret: ENC(VbnkopxrwgbFVKp+UxJ2pg==)
scope: server
resource:
loadBalanced: true
token-info-uri: http://yifu-auth/oauth/check_token
# mybaits-plus配置
mybatis-plus:
mapper-locations: classpath:/mapper/*Mapper.xml
global-config:
banner: false
db-config:
id-type: auto
table-underline: true
logic-delete-value: 1
logic-not-delete-value: 0
configuration:
map-underscore-to-camel-case: true
# 直接放行URL
ignore:
urls:
- /v2/api-docs
- /actuator/**
#spring 配置
spring:
application:
name: @artifactId@
cloud:
nacos:
discovery:
server-addr: ${NACOS_HOST:yifu-register}:${NACOS_PORT:8848}
---
# 数据源配置
spring:
redis:
host: yifu-redis
password: '@yf_2017'
datasource:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
username: root
password: yf_zsk
url: jdbc:mysql://192.168.1.65:22306/provider?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
config:
server-addr: ${spring.cloud.nacos.discovery.server-addr}
activate:
on-profile: test
---
# 数据源配置
spring:
redis:
host: yifu-redis
password: '@yf_2017'
datasource:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
username: root
password: yf_zsk
url: jdbc:mysql://192.168.1.65:22306/provider?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
config:
import:
- nacos:application-@profiles.active@.yml
- nacos:${spring.application.name}-@profiles.active@.yml
activate:
on-profile: dev
......@@ -37,10 +37,10 @@
<artifactId>yifu-common-core</artifactId>
</dependency>
<!--swagger-->
<dependency>
<!--<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId>
</dependency>
</dependency>-->
<!--feign 注解依赖-->
<!--<dependency>
<groupId>org.springframework.cloud</groupId>
......
......@@ -14,26 +14,6 @@ management:
health:
show-details: ALWAYS
# feign 配置
feign:
sentinel:
enabled: true
okhttp:
enabled: true
httpclient:
enabled: false
client:
config:
default:
connectTimeout: 10000
readTimeout: 10000
compression:
request:
enabled: true
response:
enabled: true
# mybaits-plus配置
mybatis-plus:
mapper-locations: classpath:/mapper/*Mapper.xml
......@@ -53,8 +33,8 @@ security:
resource:
loadBalanced: true
token-info-uri: http://yifu-auth/oauth/check_token
# 通用放行URL,服务个性化,请在对应配置文件覆盖
ignore:
# 通用放行URL,服务个性化,请在对应配置文件覆盖
ignore:
urls:
- /v3/api-docs
- /actuator/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment