feat(商城): 升级至Springboot3.0
parent
2361720a15
commit
e044cf1a0e
@ -1 +0,0 @@
|
||||
FROM maven:3.8.1-openjdk-11
|
@ -1,24 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# waynboot-mall项目-阿里云容器服务-docker方式部署脚本
|
||||
|
||||
app_name="waynboot_mall"
|
||||
docker_redistry_prefix="registry.cn-shanghai.aliyuncs.com/wayn111/"
|
||||
waynboot_mall=("waynboot-mobile-api:82" "waynboot-admin-api:81" "waynboot-message-consumer:85")
|
||||
|
||||
echo "${app_name}项目开始安装"
|
||||
echo "------------------------------------------------------------------"
|
||||
|
||||
for var in "${waynboot_mall[@]}"; do
|
||||
echo "${var}:初始化安装开始"
|
||||
port=${var#*:}
|
||||
name=${var%:*}
|
||||
docker stop ${name}
|
||||
docker rm ${name}
|
||||
docker rmi "${docker_redistry_prefix}${name}"
|
||||
docker pull "${docker_redistry_prefix}${name}"
|
||||
docker run -d -p ${port}:${port} --net=host --name ${name} "${docker_redistry_prefix}${name}"
|
||||
echo "${var}:初始化安装结束"
|
||||
echo "------------------------------------------------------------------"
|
||||
done
|
||||
|
||||
echo "${app_name}项目安装成功"
|
@ -1,13 +0,0 @@
|
||||
# 该镜像需要依赖的基础镜像
|
||||
FROM adoptopenjdk:11-jre-openj9
|
||||
WORKDIR /root/workspace
|
||||
# 将当前目录下的jar包复制到docker容器的/目录下
|
||||
ADD waynboot-admin-api/target/waynboot-admin-api-1.1.0.jar /opt/waynboot-mall/waynboot-admin-api-1.1.0.jar
|
||||
# 运行过程中创建一个mall-tiny-docker-file.jar文件
|
||||
RUN bash -c 'touch /opt/waynboot-mall/waynboot-admin-api-1.1.0.jar'
|
||||
# 声明服务运行在8080端口
|
||||
EXPOSE 81
|
||||
# 指定docker容器启动时运行jar包
|
||||
ENTRYPOINT ["sh", "-c", "exec java -jar -Xms812m -Xmx812m -Xss512k /opt/waynboot-mall/waynboot-admin-api-1.1.0.jar"]
|
||||
# 指定维护者的名字
|
||||
MAINTAINER wayn111
|
@ -1,28 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# 定义应用组名
|
||||
group_name='waynboot-mall'
|
||||
# 定义应用名称
|
||||
app_name='waynboot-admin-api'
|
||||
app_port=81
|
||||
# 定义应用版本
|
||||
app_version='1.1.0'
|
||||
# 定义应用环境
|
||||
profile_active='dev'
|
||||
# coding docker host
|
||||
coding_docker_host="waynaqua-docker.pkg.coding.net/wayn"
|
||||
docker stop ${app_name}
|
||||
echo '----stop container----'
|
||||
docker rm ${app_name}
|
||||
echo '----rm container----'
|
||||
docker rmi ${coding_docker_host}/${group_name}/${app_name}:${app_version}
|
||||
echo '----rm image----'
|
||||
# 获取docker镜像
|
||||
docker pull ${coding_docker_host}/${group_name}/${app_name}:${app_version}
|
||||
echo '----pull image----'
|
||||
docker run -p ${app_port}:${app_port} --name ${app_name} \
|
||||
-e 'spring.profiles.active'=${profile_active} \
|
||||
-e TZ="Asia/Shanghai" \
|
||||
-v /etc/localtime:/etc/localtime \
|
||||
-v /mydata/app/${app_name}/logs:/var/logs \
|
||||
-d ${coding_docker_host}/${group_name}/${app_name}:${app_version}
|
||||
echo '----start container----'
|
@ -1,40 +0,0 @@
|
||||
package com.wayn.admin.api.service.impl;
|
||||
|
||||
import com.anji.captcha.service.CaptchaCacheService;
|
||||
import com.wayn.data.redis.manager.RedisCache;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public class CaptchaCacheServiceRedisImpl implements CaptchaCacheService {
|
||||
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
@Override
|
||||
public void set(String key, String value, long expiresInSeconds) {
|
||||
redisCache.setCacheObject(key, value, (int) expiresInSeconds, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean exists(String key) {
|
||||
return redisCache.existsKey(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(String key) {
|
||||
redisCache.deleteObject(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get(String key) {
|
||||
return redisCache.getCacheObject(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String type() {
|
||||
return "redis";
|
||||
}
|
||||
}
|
@ -1,71 +0,0 @@
|
||||
package com.wayn.admin.framework.config;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
|
||||
import com.alibaba.druid.spring.boot.autoconfigure.properties.DruidStatProperties;
|
||||
import com.alibaba.druid.util.Utils;
|
||||
import com.wayn.admin.framework.config.properties.DruidProperties;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.servlet.*;
|
||||
import javax.sql.DataSource;
|
||||
import java.io.IOException;
|
||||
|
||||
@Configuration
|
||||
public class DruidConfig {
|
||||
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties("spring.datasource.master")
|
||||
public DataSource dataSource(DruidProperties druidProperties) {
|
||||
DruidDataSource dataSource = DruidDataSourceBuilder.create().build();
|
||||
return druidProperties.dataSource(dataSource);
|
||||
}
|
||||
|
||||
/**
|
||||
* 去除监控页面底部的广告
|
||||
*/
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
@Bean
|
||||
@ConditionalOnProperty(name = "spring.datasource.druid.statViewServlet.enabled", havingValue = "true")
|
||||
public FilterRegistrationBean removeDruidFilterRegistrationBean(DruidStatProperties properties) {
|
||||
// 获取web监控页面的参数
|
||||
DruidStatProperties.StatViewServlet config = properties.getStatViewServlet();
|
||||
// 提取common.js的配置路径
|
||||
String pattern = config.getUrlPattern() != null ? config.getUrlPattern() : "/druid/*";
|
||||
String commonJsPattern = pattern.replaceAll("\\*", "js/common.js");
|
||||
final String filePath = "support/http/resources/js/common.js";
|
||||
// 创建filter进行过滤
|
||||
Filter filter = new Filter() {
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
|
||||
throws IOException, ServletException {
|
||||
chain.doFilter(request, response);
|
||||
// 重置缓冲区,响应头不会被重置
|
||||
response.resetBuffer();
|
||||
// 获取common.js
|
||||
String text = Utils.readFromResource(filePath);
|
||||
// 正则替换banner, 除去底部的广告信息
|
||||
text = text.replaceAll("<a.*?banner\"></a><br/>", "");
|
||||
text = text.replaceAll("powered.*?shrek.wang</a>", "");
|
||||
response.getWriter().write(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
}
|
||||
};
|
||||
FilterRegistrationBean registrationBean = new FilterRegistrationBean();
|
||||
registrationBean.setFilter(filter);
|
||||
registrationBean.addUrlPatterns(commonJsPattern);
|
||||
return registrationBean;
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.wayn.admin.framework.config;
|
||||
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
@Configuration
|
||||
public class HikariCpConfig {
|
||||
|
||||
@Bean(name = "masterDataSource")
|
||||
@ConfigurationProperties(prefix = "spring.datasource.master")
|
||||
public DataSource masterDataSource() {
|
||||
return new HikariDataSource();
|
||||
}
|
||||
|
||||
|
||||
@Bean(name = "masterTransactionManager")
|
||||
public DataSourceTransactionManager masterTransactionManager(@Qualifier("masterDataSource") DataSource dataSource) {
|
||||
return new DataSourceTransactionManager(dataSource);
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
package com.wayn.admin.framework.manager.datasource.thread;
|
||||
|
||||
|
||||
import com.wayn.common.enums.DataSourceEnum;
|
||||
|
||||
/**
|
||||
* 数据库切换threadLocal
|
||||
*/
|
||||
public class DataSourceHolder {
|
||||
private static ThreadLocal<DataSourceEnum> dataSourceEnumThreadLocal = ThreadLocal.withInitial(() -> DataSourceEnum.MASTER);
|
||||
|
||||
public static void set(DataSourceEnum dataSourceEnum) {
|
||||
dataSourceEnumThreadLocal.set(dataSourceEnum);
|
||||
}
|
||||
|
||||
public static DataSourceEnum get() {
|
||||
return dataSourceEnumThreadLocal.get();
|
||||
}
|
||||
|
||||
public static void remove() {
|
||||
dataSourceEnumThreadLocal.remove();
|
||||
}
|
||||
|
||||
}
|
@ -1 +0,0 @@
|
||||
com.wayn.admin.api.service.impl.CaptchaCacheServiceRedisImpl
|
@ -1,42 +0,0 @@
|
||||
# druid数据源配置
|
||||
spring:
|
||||
datasource:
|
||||
druid:
|
||||
initialSize: 10
|
||||
# 最小连接池数量
|
||||
minIdle: 10
|
||||
# 最大连接池数量
|
||||
maxActive: 50
|
||||
# 配置获取连接等待超时的时间
|
||||
# maxWait: 60000
|
||||
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
|
||||
timeBetweenEvictionRunsMillis: 60000
|
||||
# 配置一个连接在池中最小生存的时间,单位是毫秒
|
||||
minEvictableIdleTimeMillis: 300000
|
||||
# 配置一个连接在池中最大生存的时间,单位是毫秒
|
||||
maxEvictableIdleTimeMillis: 900000
|
||||
# 配置检测连接是否有效
|
||||
validationQuery: SELECT 1
|
||||
testWhileIdle: true
|
||||
testOnBorrow: false
|
||||
testOnReturn: false
|
||||
webStatFilter:
|
||||
enabled: true
|
||||
statViewServlet:
|
||||
enabled: true
|
||||
# 设置白名单,不填则允许所有访问
|
||||
allow:
|
||||
url-pattern: /druid/*
|
||||
# 控制台管理用户名和密码
|
||||
login-username:
|
||||
login-password:
|
||||
filter:
|
||||
stat:
|
||||
enabled: true
|
||||
# 慢SQL记录
|
||||
log-slow-sql: true
|
||||
slow-sql-millis: 1000
|
||||
merge-sql: true
|
||||
wall:
|
||||
config:
|
||||
multi-statement-allow: true
|
@ -0,0 +1,27 @@
|
||||
package com.wayn.data.elastic.config;
|
||||
|
||||
import org.apache.http.HttpHost;
|
||||
import org.elasticsearch.client.RestClient;
|
||||
import org.elasticsearch.client.RestClientBuilder;
|
||||
import org.elasticsearch.client.RestHighLevelClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class ElasticClientConfig {
|
||||
@Bean
|
||||
public RestClientBuilder restClientBuilder(ElasticConfig config) {
|
||||
return RestClient.builder(new HttpHost(config.getHost(), config.getPort(), config.getScheme()));
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RestClient elasticsearchRestClient(ElasticConfig config) {
|
||||
return RestClient.builder(new HttpHost(config.getHost(), config.getPort(), config.getScheme())).build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RestHighLevelClient restHighLevelClient(@Autowired RestClientBuilder restClientBuilder) {
|
||||
return new RestHighLevelClient(restClientBuilder);
|
||||
}
|
||||
}
|
@ -1,45 +1,56 @@
|
||||
package com.wayn.data.elastic.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.apache.http.HttpHost;
|
||||
import org.elasticsearch.client.RestClient;
|
||||
import org.elasticsearch.client.RestClientBuilder;
|
||||
import org.elasticsearch.client.RestHighLevelClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Data
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "es.config")
|
||||
public class ElasticConfig {
|
||||
@Value("${es.host}")
|
||||
public String host;
|
||||
@Value("${es.port}")
|
||||
public int port;
|
||||
@Value("${es.scheme}")
|
||||
public String scheme;
|
||||
@Value("${es.shards}")
|
||||
public int shards;
|
||||
@Value("${es.replicas}")
|
||||
public int replicas;
|
||||
|
||||
@Bean
|
||||
public RestClientBuilder restClientBuilder() {
|
||||
return RestClient.builder(makeHttpHost());
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setPort(int port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public String getScheme() {
|
||||
return scheme;
|
||||
}
|
||||
|
||||
public void setScheme(String scheme) {
|
||||
this.scheme = scheme;
|
||||
}
|
||||
|
||||
public int getShards() {
|
||||
return shards;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RestClient elasticsearchRestClient() {
|
||||
return RestClient.builder(new HttpHost(host, port, scheme)).build();
|
||||
public void setShards(int shards) {
|
||||
this.shards = shards;
|
||||
}
|
||||
|
||||
private HttpHost makeHttpHost() {
|
||||
return new HttpHost(host, port, scheme);
|
||||
public int getReplicas() {
|
||||
return replicas;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RestHighLevelClient restHighLevelClient(@Autowired RestClientBuilder restClientBuilder) {
|
||||
return new RestHighLevelClient(restClientBuilder);
|
||||
public void setReplicas(int replicas) {
|
||||
this.replicas = replicas;
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue