diff --git a/ReadMe.md b/ReadMe.md new file mode 100644 index 0000000..3a4cd05 --- /dev/null +++ b/ReadMe.md @@ -0,0 +1,384 @@ +# Spring模板 + +每个服务下都有`Dockerfile`文件,几乎是写好的模板,如果要添加在这基础上即可。 + +- 基础包有 + - 邮件发送 + - WebSocket + - Minio + - Redis + - rabbitMq + - velocity + - IP地址查询 + - knife4j + - 数据库多源配置 + + +## 基础配置 + +### 配置文件详情 + +### 打包命令 + +命令解释:清理之前内容,打包,使用生产环境,跳过测试 + +```shell +mvn clean package -Pprod -DskipTests +``` + +#### SpringBoot配置文件 + +在开发中需要使用到开发环境、上线需要生产环境,在环境中设置`@profiles.active@`可以根据不同环境切换 + +```yaml +spring: + profiles: + active: @profiles.active@ + application: + name: service-admin +``` + +只需要在IDE中勾选相关环境即可 + +![image-20240822093552802](./images/image-20240822093552802.png) + +> 注意!!! +> +> 因为Java每次启动都需要生成target,有缓存在里面,很有可能明明选择了配置但是没有生效的情况。 +> +> 解决办法就是,每次改变环境执行`mvn clean`或者点击IDE中`mvn clean` +> +> ![image-20240822093803078](./images/image-20240822093803078.png) + +### Dockerfile配置 + +如果需要访问宿主机文件目录,这个是Docker内部地址 + +```dockerfile +# 程序内部挂在目录 +VOLUME /home/server/uploads +``` + +#### IDE中配置 + +![image-20240822094021339](./images/image-20240822094021339.png) + +![image-20240822094000542](./images/image-20240822094000542.png) + +### 整体返回响应 + +整体返回响应如下 + +```java +// 状态码 +private Integer code; +// 返回消息 +private String message; +// 返回数据 +private T data; +``` + +![image-20240822092441020](./images/image-20240822092441020.png) + +和分页返回 + +```java +/** + * 封装分页查询结果 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class ResultPage implements Serializable { + // 当前页 + private Integer pageNo; + // 每页记录数 + private Integer pageSize; + // 总记录数 + private long total; + // 当前页数据集合 + private List list; +} +``` + +以及常用的枚举状态码(展示部分) + +![image-20240822092510151](./images/image-20240822092510151.png) + +### 多数据库源配置 + +开发中有时会使用到多个数据库源,这个配置也是来自MybatisPlus官方推荐的库 + +```xml + + + com.baomidou + dynamic-datasource-spring-boot3-starter + 4.3.1 + +``` + +#### 配置简介 + +如果不需要多数据库,移除包之后将注释的部分放开,删除`dynamic`节点以下内容 + +```java +datasource: + # type: com.zaxxer.hikari.HikariDataSource + # driver-class-name: com.mysql.cj.jdbc.Driver + # url: jdbc:mysql://${bunny.datasource.host}:${bunny.datasource.port}/${bunny.datasource.sqlData}?serverTimezone=GMT%2B8&useSSL=false&characterEncoding=utf-8&allowPublicKeyRetrieval=true + # username: ${bunny.datasource.username} + # password: ${bunny.datasource.password} + dynamic: + primary: master #设置默认的数据源或者数据源组,默认值即为master + strict: false #严格匹配数据源,默认false. true未匹配到指定数据源时抛异常,false使用默认数据源 + grace-destroy: false #是否优雅关闭数据源,默认为false,设置为true时,关闭数据源时如果数据源中还存在活跃连接,至多等待10s后强制关闭 + datasource: + master: + type: com.zaxxer.hikari.HikariDataSource + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://${bunny.datasource.host}:${bunny.datasource.port}/${bunny.datasource.sqlData}?serverTimezone=GMT%2B8&useSSL=false&characterEncoding=utf-8&allowPublicKeyRetrieval=true + username: ${bunny.datasource.username} + password: ${bunny.datasource.password} + aop: + enabled: true +``` + +## 中间件配置 + +### mybatis-plus + +#### 配置详情 + +配置乐观锁、防止全表删除、最大分页100页 + +`common/service-utils/src/main/java/cn/bunny/common/service/config/MybatisPlusConfig.java` + +```java +/** + * Mybatis-Plus配置类 + */ +@EnableTransactionManagement +@Configuration +@Slf4j +public class MybatisPlusConfig { + @Bean + public MybatisPlusInterceptor mybatisPlusInterceptor() { + MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); + // 分页插件 + PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor(DbType.MYSQL); + paginationInnerInterceptor.setMaxLimit(100L);// 设置最大分页为100 + interceptor.addInnerInterceptor(paginationInnerInterceptor); + // 乐观锁 + interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor()); + // 防止全表删除 + interceptor.addInnerInterceptor(new BlockAttackInnerInterceptor()); + + return interceptor; + } +} +``` + +如果如要插入和修改时,自定义时间或者其它可以在这设置 + +`common/service-utils/src/main/java/cn/bunny/common/service/config/MyBatisPlusFieldConfig.java` + +```java +/** + * 配置MP在修改和新增时的操作 + */ +@Component +public class MyBatisPlusFieldConfig implements MetaObjectHandler { + + /** + * 使用mp做添加操作时候,这个方法执行 + */ + @Override + public void insertFill(MetaObject metaObject) { + // 设置属性值 + this.setFieldValByName("createTime", new Date(), metaObject); + this.setFieldValByName("updateTime", new Date(), metaObject); + this.setFieldValByName("deleteStatus", 1, metaObject); + if (BaseContext.getUsername() != null) { + this.setFieldValByName("createBy", BaseContext.getUsername(), metaObject); + this.setFieldValByName("updateBy", BaseContext.getUsername(), metaObject); + } + } + + /** + * 使用mp做修改操作时候,这个方法执行 + */ + @Override + public void updateFill(MetaObject metaObject) { + this.setFieldValByName("updateTime", new Date(), metaObject); + this.setFieldValByName("updateBy", BaseContext.getUsername(), metaObject); + } +} +``` + +### Redis + +#### 配置详情 + +分别设置了过期30天、1小时、3分钟 + +`common/service-utils/src/main/java/cn/bunny/common/service/config/RedisConfiguration.java` + +```java +/** + * * 配置Redis过期时间30天 + * 解决cache(@Cacheable)把数据缓存到redis中的value是乱码问题 + */ +@Bean +@Primary +@SuppressWarnings("all") +public CacheManager cacheManagerWithMouth(RedisConnectionFactory factory) { + // 配置序列化 + RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig() + .serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(new StringRedisSerializer())) + .serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(jsonRedisSerializer())) + .entryTtl(Duration.ofDays(30)); + + return RedisCacheManager.builder(factory).cacheDefaults(config).build(); +} + +/** + * * 配置redis过期时间3分钟 + * + * @param factory + * @return + */ +@Bean +@SuppressWarnings("all") +public CacheManager cacheManagerWithMinutes(RedisConnectionFactory factory) { + // 配置序列化 + RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig() + .serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(new StringRedisSerializer())) + .serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(jsonRedisSerializer())) + .entryTtl(Duration.ofMinutes(3)); + + return RedisCacheManager.builder(factory).cacheDefaults(config).build(); +} + +/** + * * 配置Redis过期时间1小时 + * + * @param factory + * @return + */ +@Bean +@SuppressWarnings("all") +public CacheManager cacheManagerWithHours(RedisConnectionFactory factory) { + // 配置序列化 + RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig() + .serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(new StringRedisSerializer())) + .serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(jsonRedisSerializer())) + .entryTtl(Duration.ofHours(1)); + + return RedisCacheManager.builder(factory).cacheDefaults(config).build(); +} +``` + +#### 使用详情 + +如果需要指定Redis配置,`cacheManager="Redis配置中方法名"` + +使用springCache只需要在方法上加上下面代码 + +```java +@Cacheable(value = "TaskStatistics", key = "'ByDepartment::'+#departmentName", + cacheManager = "cacheManagerWithMinutes") +``` + +### Minio + +#### 配置详情 + +Minio没有给出SpringBoot的配置文件,下面是自定义实现 + +`module/module-minio/src/main/java/cn/bunny/module/minio/properties/MinioProperties.java` + +在配置文件中有这4个配置字段 + +```java +@Configuration +@ConfigurationProperties(prefix = "bunny.minio") +@ConditionalOnProperty(name = "bunny.minio.bucket-name")// 当属性有值时这个配置才生效 +@Data +@Slf4j +public class MinioProperties { + private String endpointUrl; + private String accessKey; + private String secretKey; + private String bucketName; + + @Bean + public MinioClient minioClient() { + log.info("注册MinioClient..."); + return MinioClient.builder().endpoint(endpointUrl).credentials(accessKey, secretKey).build(); + } +} +``` + +在项目中加入了Minio常用工具方法,对Minio二次封装 + +![image-20240822091720866](./images/image-20240822091720866.png) + +### 邮箱发送 + +邮箱发送配置的是动态邮件,发件人是动态的不是写死在配置文件中 + +![image-20240822091810597](./images/image-20240822091810597.png) + +#### 配置文件 + +如果不需要动态配置可以在`SpringBoot`配置文件中加入下面的配置 + +```properties +mail: + host: smtp.qq.com # 邮箱地址 + port: 465 # 邮箱端口号 + username: xxx@qq.com # 设置发送邮箱 + password: xx # 如果是纯数字要加引号 + default-encoding: UTF-8 # 设置编码格式 + protocol: smtps + properties: + mail: + debug: true # 是否开启debug模式发送邮件 + smtp: + auth: true + connectionTimeout: 5000 # 设置连接延迟 + timeout: 5000 # 延迟时间 + writeTimeout: 5000 # 写入邮箱延迟 + allow8BitMime: true + sendPartial: true + ssl: + enabled: true # 是否开启SSL连接 + socketFactory: + class: javax.net.ssl.SSLSocketFactory # 必要设置!!! +``` + +### SpringSecurity + +因为项目做的是开发模板,在admin模板中集成了安全框架 + +`module/spring-security/src/main/java/cn/bunny/security/config/WebSecurityConfig.java` + +在这个文件最下面是排除路径,不需要Security检测的路径,根据自己需求进行修改,因为整合了knife4j在测试时,需要放开swagger配置响应请求等。 + +```java +/** + * * 排出鉴定路径 + * + * @return WebSecurityCustomizer + */ +@Bean +public WebSecurityCustomizer webSecurityCustomizer() { + String[] annotations = {"/", "/test/**", "/diagram-viewer/**", "/editor-app/**", "/*.html", + "/*/*/noAuth/**", "/*/noAuth/**", "/favicon.ico", "/swagger-resources/**", "/webjars/**", + "/v3/**", "/swagger-ui.html/**", "/doc.html"}; + return web -> web.ignoring().requestMatchers(annotations); +} +``` + diff --git a/common/service-utils/src/main/java/cn/bunny/common/service/config/MybatisPlusConfig.java b/common/service-utils/src/main/java/cn/bunny/common/service/config/MybatisPlusConfig.java index 519a465..1d680c1 100644 --- a/common/service-utils/src/main/java/cn/bunny/common/service/config/MybatisPlusConfig.java +++ b/common/service-utils/src/main/java/cn/bunny/common/service/config/MybatisPlusConfig.java @@ -19,8 +19,6 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; public class MybatisPlusConfig { @Bean public MybatisPlusInterceptor mybatisPlusInterceptor() { - log.info("MybatisPlusInterceptor===>注入Mybatis-Plus配置..."); - MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); // 分页插件 PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor(DbType.MYSQL); diff --git a/common/service-utils/src/main/java/cn/bunny/common/service/config/RedisConfiguration.java b/common/service-utils/src/main/java/cn/bunny/common/service/config/RedisConfiguration.java index 1b5c8d7..c82936b 100644 --- a/common/service-utils/src/main/java/cn/bunny/common/service/config/RedisConfiguration.java +++ b/common/service-utils/src/main/java/cn/bunny/common/service/config/RedisConfiguration.java @@ -13,6 +13,7 @@ import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; import lombok.extern.slf4j.Slf4j; import org.springframework.cache.CacheManager; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Primary; import org.springframework.data.redis.cache.RedisCacheConfiguration; import org.springframework.data.redis.cache.RedisCacheManager; import org.springframework.data.redis.connection.RedisConnectionFactory; @@ -40,8 +41,6 @@ public class RedisConfiguration { */ @Bean public RedisTemplate redisTemplate(LettuceConnectionFactory connectionFactory) { - log.info("RedisConfiguration===>使用StringRedisSerializer序列化为字符串"); - RedisTemplate redisTemplate = new RedisTemplate<>(); redisTemplate.setConnectionFactory(connectionFactory); // 设置key序列化为string @@ -55,13 +54,13 @@ public class RedisConfiguration { } /** + * * 配置Redis过期时间30天 * 解决cache(@Cacheable)把数据缓存到redis中的value是乱码问题 */ @Bean + @Primary @SuppressWarnings("all") - public CacheManager cacheManager(RedisConnectionFactory factory) { - log.info("RedisConfiguration===>解决cache(@Cacheable)把数据缓存到redis中的value是乱码问题"); - + public CacheManager cacheManagerWithMouth(RedisConnectionFactory factory) { // 配置序列化 RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig() .serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(new StringRedisSerializer())) @@ -71,12 +70,46 @@ public class RedisConfiguration { return RedisCacheManager.builder(factory).cacheDefaults(config).build(); } + /** + * * 配置redis过期时间3分钟 + * + * @param factory + * @return + */ + @Bean + @SuppressWarnings("all") + public CacheManager cacheManagerWithMinutes(RedisConnectionFactory factory) { + // 配置序列化 + RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig() + .serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(new StringRedisSerializer())) + .serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(jsonRedisSerializer())) + .entryTtl(Duration.ofMinutes(3)); + + return RedisCacheManager.builder(factory).cacheDefaults(config).build(); + } + + /** + * * 配置Redis过期时间1小时 + * + * @param factory + * @return + */ + @Bean + @SuppressWarnings("all") + public CacheManager cacheManagerWithHours(RedisConnectionFactory factory) { + // 配置序列化 + RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig() + .serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(new StringRedisSerializer())) + .serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(jsonRedisSerializer())) + .entryTtl(Duration.ofHours(1)); + + return RedisCacheManager.builder(factory).cacheDefaults(config).build(); + } + /** * 指定的日期模式 */ public Jackson2JsonRedisSerializer jsonRedisSerializer() { - log.info("RedisConfiguration===>指定的日期模式"); - ObjectMapper mapper = new ObjectMapper(); // 设置ObjectMapper访问权限 mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); diff --git a/common/service-utils/src/main/java/cn/bunny/common/service/config/WebMvcConfiguration.java b/common/service-utils/src/main/java/cn/bunny/common/service/config/WebMvcConfiguration.java index 160e058..1cf0faa 100644 --- a/common/service-utils/src/main/java/cn/bunny/common/service/config/WebMvcConfiguration.java +++ b/common/service-utils/src/main/java/cn/bunny/common/service/config/WebMvcConfiguration.java @@ -30,8 +30,6 @@ public class WebMvcConfiguration implements WebMvcConfigurer { @Override public void addInterceptors(InterceptorRegistry registry) { - // log.info("WebMvcConfiguration===>开始注册自定义拦截器..."); - // TODO Spring Security 和这个拦截器任选一个 String[] excludeList = {"/", "/test/**", "/*.html", "/*/*/noAuth/**", "/*/noAuth/**", "/favicon.ico", "/swagger-resources/**", "/swagger-ui.html/**", "/admin/login", "/v3/**", "/api/**"}; diff --git a/common/service-utils/src/main/java/cn/bunny/common/service/interceptor/UserTokenInterceptor.java b/common/service-utils/src/main/java/cn/bunny/common/service/interceptor/UserTokenInterceptor.java index 1866a96..2f435bb 100644 --- a/common/service-utils/src/main/java/cn/bunny/common/service/interceptor/UserTokenInterceptor.java +++ b/common/service-utils/src/main/java/cn/bunny/common/service/interceptor/UserTokenInterceptor.java @@ -10,6 +10,7 @@ import cn.bunny.vo.system.login.LoginVo; import com.alibaba.fastjson2.JSONObject; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import lombok.NonNull; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; @@ -20,6 +21,10 @@ import org.springframework.web.servlet.HandlerInterceptor; import java.util.Map; +/** + * * 微服务请求其它模块找不到Token,无法从线程中获取值 + * 传递请求头,在微服务中 + */ @Component @Slf4j public class UserTokenInterceptor implements HandlerInterceptor { @@ -27,8 +32,7 @@ public class UserTokenInterceptor implements HandlerInterceptor { private RedisTemplate redisTemplate; @Override - public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { - log.info("UserTokenInterceptor===>设置拦截器"); + public boolean preHandle(HttpServletRequest request, @NonNull HttpServletResponse response, @NonNull Object handler) throws Exception { String token = request.getHeader("token"); Map mapByToken = JwtHelper.getMapByToken(token); LoginVo loginVo = JSONObject.parseObject(JSONObject.toJSONString(mapByToken), LoginVo.class); diff --git a/common/service-utils/src/main/java/cn/bunny/common/service/utils/IpUtil.java b/common/service-utils/src/main/java/cn/bunny/common/service/utils/IpUtil.java index c1d83f6..da4ffe7 100644 --- a/common/service-utils/src/main/java/cn/bunny/common/service/utils/IpUtil.java +++ b/common/service-utils/src/main/java/cn/bunny/common/service/utils/IpUtil.java @@ -1,6 +1,7 @@ package cn.bunny.common.service.utils; import jakarta.annotation.PostConstruct; +import lombok.extern.slf4j.Slf4j; import org.lionsoul.ip2region.xdb.Searcher; import org.springframework.core.io.ClassPathResource; import org.springframework.util.FileCopyUtils; @@ -9,6 +10,7 @@ import java.io.InputStream; import java.util.regex.Matcher; import java.util.regex.Pattern; +@Slf4j public class IpUtil { private static Searcher searcher; @@ -32,7 +34,7 @@ public class IpUtil { byte[] bytes = FileCopyUtils.copyToByteArray(inputStream); searcher = Searcher.newWithBuffer(bytes); } catch (Exception exception) { - exception.printStackTrace(); + log.error(exception.getMessage()); } } @@ -66,8 +68,8 @@ public class IpUtil { return splitIpInfo[0]; } } - } catch (Exception e) { - e.printStackTrace(); + } catch (Exception exception) { + log.error(exception.getMessage()); } return ""; } else { diff --git a/dao/src/main/java/cn/bunny/vo/page/PageResult.java b/dao/src/main/java/cn/bunny/pojo/result/PageResult.java similarity index 94% rename from dao/src/main/java/cn/bunny/vo/page/PageResult.java rename to dao/src/main/java/cn/bunny/pojo/result/PageResult.java index feb66b2..8cb413e 100644 --- a/dao/src/main/java/cn/bunny/vo/page/PageResult.java +++ b/dao/src/main/java/cn/bunny/pojo/result/PageResult.java @@ -1,4 +1,4 @@ -package cn.bunny.vo.page; +package cn.bunny.pojo.result; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/images/image-20240822091720866.png b/images/image-20240822091720866.png new file mode 100644 index 0000000..cefa1e5 Binary files /dev/null and b/images/image-20240822091720866.png differ diff --git a/images/image-20240822091810597.png b/images/image-20240822091810597.png new file mode 100644 index 0000000..2cfbd29 Binary files /dev/null and b/images/image-20240822091810597.png differ diff --git a/images/image-20240822092441020.png b/images/image-20240822092441020.png new file mode 100644 index 0000000..5b92d62 Binary files /dev/null and b/images/image-20240822092441020.png differ diff --git a/images/image-20240822092510151.png b/images/image-20240822092510151.png new file mode 100644 index 0000000..e822d45 Binary files /dev/null and b/images/image-20240822092510151.png differ diff --git a/images/image-20240822093552802.png b/images/image-20240822093552802.png new file mode 100644 index 0000000..0d6e6a9 Binary files /dev/null and b/images/image-20240822093552802.png differ diff --git a/images/image-20240822093803078.png b/images/image-20240822093803078.png new file mode 100644 index 0000000..cd507f3 Binary files /dev/null and b/images/image-20240822093803078.png differ diff --git a/images/image-20240822094000542.png b/images/image-20240822094000542.png new file mode 100644 index 0000000..ca37d8f Binary files /dev/null and b/images/image-20240822094000542.png differ diff --git a/images/image-20240822094021339.png b/images/image-20240822094021339.png new file mode 100644 index 0000000..ade461f Binary files /dev/null and b/images/image-20240822094021339.png differ diff --git a/module/module-mail/src/main/java/cn/bunny/module/mail/template-propties b/module/module-mail/src/main/java/cn/bunny/module/mail/template-propties index cc51c94..2ce3978 100644 --- a/module/module-mail/src/main/java/cn/bunny/module/mail/template-propties +++ b/module/module-mail/src/main/java/cn/bunny/module/mail/template-propties @@ -1,5 +1,3 @@ -Configuration example - mail: host: smtp.qq.com # 邮箱地址 port: 465 # 邮箱端口号 diff --git a/module/module-task/pom.xml b/module/module-task/pom.xml deleted file mode 100644 index 3ab04f3..0000000 --- a/module/module-task/pom.xml +++ /dev/null @@ -1,23 +0,0 @@ - - 4.0.0 - - cn.bunny - module - 0.0.1-SNAPSHOT - - - module-task - jar - - module-task - https://maven.apache.org - - - UTF-8 - - - - - - diff --git a/module/module-websocket/pom.xml b/module/module-websocket/pom.xml deleted file mode 100644 index e3b9b40..0000000 --- a/module/module-websocket/pom.xml +++ /dev/null @@ -1,27 +0,0 @@ - - 4.0.0 - - cn.bunny - module - 0.0.1-SNAPSHOT - - - module-websocket - jar - - module-websocket - https://maven.apache.org - - - UTF-8 - - - - - - org.springframework.boot - spring-boot-starter-websocket - - - diff --git a/module/module-websocket/src/main/java/cn/bunny/module/websocket/config/WebSocketConfiguration.java b/module/module-websocket/src/main/java/cn/bunny/module/websocket/config/WebSocketConfiguration.java deleted file mode 100644 index 8df905f..0000000 --- a/module/module-websocket/src/main/java/cn/bunny/module/websocket/config/WebSocketConfiguration.java +++ /dev/null @@ -1,13 +0,0 @@ -package cn.bunny.module.websocket.config; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.socket.server.standard.ServerEndpointExporter; - -@Configuration -public class WebSocketConfiguration { - @Bean - public ServerEndpointExporter endpointExporter() { - return new ServerEndpointExporter(); - } -} diff --git a/module/pom.xml b/module/pom.xml index cc81d26..e415333 100644 --- a/module/pom.xml +++ b/module/pom.xml @@ -16,9 +16,7 @@ module-minio module-mail module-rabbitMQ - module-websocket spring-security - module-task diff --git a/service/Dockerfile b/service/Dockerfile index 9c9d24f..c799d18 100644 --- a/service/Dockerfile +++ b/service/Dockerfile @@ -20,5 +20,4 @@ ENTRYPOINT ["java","-jar","/home/bunny/app.jar"] #暴露 8800 端口 EXPOSE 8080 -# maven 打包 -# mvn clean package -Pprod -DskipTests \ No newline at end of file +# maven 打包:mvn clean package -Pprod -DskipTests \ No newline at end of file diff --git a/service/pom.xml b/service/pom.xml index 60266e8..a3371a5 100644 --- a/service/pom.xml +++ b/service/pom.xml @@ -70,6 +70,11 @@ org.aspectj aspectjweaver + + + org.springframework.boot + spring-boot-starter-websocket + com.baomidou diff --git a/module/module-task/src/main/java/cn/bunny/module/task/TemplateTask.java b/service/src/main/java/cn/bunny/service/task/TemplateTask.java similarity index 91% rename from module/module-task/src/main/java/cn/bunny/module/task/TemplateTask.java rename to service/src/main/java/cn/bunny/service/task/TemplateTask.java index 2dbf0b7..d28941b 100644 --- a/module/module-task/src/main/java/cn/bunny/module/task/TemplateTask.java +++ b/service/src/main/java/cn/bunny/service/task/TemplateTask.java @@ -1,4 +1,4 @@ -package cn.bunny.module.task; +package cn.bunny.service.task; import lombok.extern.slf4j.Slf4j; import org.springframework.scheduling.annotation.Scheduled; diff --git a/module/module-websocket/src/main/java/cn/bunny/module/websocket/WebSocketServer.java b/service/src/main/java/cn/bunny/service/ws/WebSocketServer.java similarity index 98% rename from module/module-websocket/src/main/java/cn/bunny/module/websocket/WebSocketServer.java rename to service/src/main/java/cn/bunny/service/ws/WebSocketServer.java index 2d84cc6..e6a9f8e 100644 --- a/module/module-websocket/src/main/java/cn/bunny/module/websocket/WebSocketServer.java +++ b/service/src/main/java/cn/bunny/service/ws/WebSocketServer.java @@ -1,4 +1,4 @@ -package cn.bunny.module.websocket; +package cn.bunny.service.ws; import jakarta.websocket.OnClose; import jakarta.websocket.OnMessage;