Compare commits
1 Commits
master
...
springboot
| Author | SHA1 | Date | |
|---|---|---|---|
| e4aa453e39 |
10
DockerFileJava25
Normal file
10
DockerFileJava25
Normal file
@@ -0,0 +1,10 @@
|
||||
FROM eclipse-temurin:25-jdk-jammy
|
||||
MAINTAINER TongTongStudio <tongtongstudios@gmail.com>
|
||||
RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak
|
||||
|
||||
RUN mkdir -p /data/uploads/
|
||||
|
||||
VOLUME /tmp
|
||||
ADD target/*.jar app.jar
|
||||
EXPOSE 8088
|
||||
ENTRYPOINT ["java", "-jar", "/app.jar"]
|
||||
14
pom.xml
14
pom.xml
@@ -12,7 +12,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>3.5.4</version>
|
||||
<version>4.0.1</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>com.onekeycall</groupId>
|
||||
@@ -34,7 +34,7 @@
|
||||
<url/>
|
||||
</scm>
|
||||
<properties>
|
||||
<java.version>21</java.version>
|
||||
<java.version>25</java.version>
|
||||
<spring-cloud.version>2025.0.0</spring-cloud.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
@@ -89,8 +89,12 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-oauth2-client</artifactId>
|
||||
<artifactId>spring-boot-starter-security-oauth2-client</artifactId>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-starter-oauth2-client</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
|
||||
@@ -108,7 +112,7 @@
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>3.0.3</version>
|
||||
<version>4.0.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -200,7 +204,7 @@
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt-jackson</artifactId>
|
||||
<version>0.12.3</version>
|
||||
<version>0.12.6</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<!-- 腾讯云短信服务 -->
|
||||
|
||||
@@ -9,6 +9,7 @@ import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration;
|
||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
||||
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
@@ -18,7 +19,7 @@ import org.springframework.security.web.authentication.UsernamePasswordAuthentic
|
||||
|
||||
@Configuration
|
||||
@EnableWebSecurity
|
||||
@EnableGlobalMethodSecurity(prePostEnabled = true)
|
||||
@EnableMethodSecurity
|
||||
public class SecurityConfig {
|
||||
|
||||
private final JwtAuthenticationFilter jwtAuthenticationFilter; // 自定义的JWT认证过滤器
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.onekeycall.videotablet.controller.sn;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.onekeycall.videotablet.bean.ApkUploadRequest;
|
||||
import com.onekeycall.videotablet.entity.ApkInfo;
|
||||
import com.onekeycall.videotablet.result.Result;
|
||||
@@ -17,12 +16,6 @@ import java.util.List;
|
||||
public class DeviceApkInfoController {
|
||||
static Logger logger = LoggerFactory.getLogger(DeviceApkInfoController.class);
|
||||
|
||||
private final ObjectMapper objectMapper; // Spring默认已注入
|
||||
|
||||
public DeviceApkInfoController(ObjectMapper objectMapper) {
|
||||
this.objectMapper = objectMapper;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private DeviceApkInfoService deviceApkInfoService;
|
||||
|
||||
|
||||
@@ -33,6 +33,9 @@ import java.nio.charset.StandardCharsets;
|
||||
public class JwtAuthenticationFilter extends OncePerRequestFilter {
|
||||
Logger logger = LoggerFactory.getLogger(JwtAuthenticationFilter.class);
|
||||
|
||||
// 推荐的缓存上限:20480字节 = 20KB,Spring5.x的默认值
|
||||
private static final int DEFAULT_CACHE_LIMIT = 20480;
|
||||
|
||||
private final UserService userService;
|
||||
|
||||
private final JwtUtil jwtUtil;
|
||||
@@ -44,7 +47,7 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter {
|
||||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
|
||||
FilterChain filterChain) throws ServletException, IOException {
|
||||
// 使用ContentCachingRequestWrapper包装请求以支持多次读取
|
||||
ContentCachingRequestWrapper wrappedRequest = new ContentCachingRequestWrapper(request);
|
||||
ContentCachingRequestWrapper wrappedRequest = new ContentCachingRequestWrapper(request, DEFAULT_CACHE_LIMIT);
|
||||
|
||||
String uripath = wrappedRequest.getRequestURI();
|
||||
// 新增请求路径日志
|
||||
@@ -77,7 +80,7 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter {
|
||||
setUnauthorizedResponse(response, Result.unAuthorized().message("Invalid credentials"));
|
||||
return; // 重要!验证失败时终止过滤器链
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
logger.error("Authorization header format error | Header: " + authorizationHeader);
|
||||
setUnauthorizedResponse(response, Result.unAuthorized().message("Authorization header format error"));
|
||||
return; // 重要!验证失败时终止过滤器链
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
spring.application.name=VideoTablet
|
||||
server.port=8088
|
||||
|
||||
spring.threads.virtual.enabled=true
|
||||
|
||||
## mysql 数据连接信息
|
||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/video_tablet_db?useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true
|
||||
@@ -23,11 +25,11 @@ spring.data.redis.lettuce.pool.max-wait=1ms
|
||||
spring.data.redis.lettuce.shutdown-timeout=100ms
|
||||
|
||||
#MongoDB
|
||||
spring.data.mongodb.uri=mongodb://fht:fanhuitong@139.199.77.221:27027/device_apks?authSource=admin&connectTimeoutMS=5000
|
||||
spring.mongodb.uri=mongodb://fht:fanhuitong@139.199.77.221:27027/device_apks?authSource=admin&connectTimeoutMS=5000
|
||||
|
||||
# Hibernate配置
|
||||
#spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MariaDBDialect
|
||||
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect
|
||||
#spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect
|
||||
spring.jpa.hibernate.ddl-auto=update
|
||||
spring.jpa.show-sql=true
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
spring.application.name=VideoTablet
|
||||
server.port=8088
|
||||
|
||||
spring.threads.virtual.enabled=true
|
||||
|
||||
## mysql 数据连接信息
|
||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
spring.datasource.url=jdbc:mysql://139.199.77.221:13306/video_tablet_db?useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true
|
||||
@@ -23,11 +25,11 @@ spring.data.redis.lettuce.pool.max-wait=1ms
|
||||
spring.data.redis.lettuce.shutdown-timeout=100ms
|
||||
|
||||
#MongoDB
|
||||
spring.data.mongodb.uri=mongodb://fht:fanhuitong@139.199.77.221:27027/device_apks?authSource=admin&connectTimeoutMS=5000
|
||||
spring.mongodb.uri=mongodb://fht:fanhuitong@139.199.77.221:27027/device_apks?authSource=admin&connectTimeoutMS=5000
|
||||
|
||||
# Hibernate配置
|
||||
#spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MariaDBDialect
|
||||
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect
|
||||
#spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect
|
||||
spring.jpa.hibernate.ddl-auto=update
|
||||
spring.jpa.show-sql=true
|
||||
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
spring.application.name=VideoTablet
|
||||
server.port=8088
|
||||
|
||||
## mysql 数据连接信息
|
||||
#spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
#spring.datasource.url=jdbc:mysql://139.199.77.221:13306/video_tablet_db?useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true
|
||||
#spring.datasource.username=tt
|
||||
#spring.datasource.password=fanhuitong
|
||||
spring.threads.virtual.enabled=true
|
||||
|
||||
# PostgreSQL 数据源配置
|
||||
spring.datasource.url=jdbc:postgresql://139.199.77.221:5433/video_tablet_db
|
||||
spring.datasource.username=postgres
|
||||
# mysql 数据连接信息
|
||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
spring.datasource.url=jdbc:mysql://139.199.77.221:13306/video_tablet_db?useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true
|
||||
spring.datasource.username=tt
|
||||
spring.datasource.password=fanhuitong
|
||||
spring.datasource.driver-class-name=org.postgresql.Driver
|
||||
|
||||
## PostgreSQL 数据源配置
|
||||
#spring.datasource.url=jdbc:postgresql://139.199.77.221:5433/video_tablet_db
|
||||
#spring.datasource.username=postgres
|
||||
#spring.datasource.password=fanhuitong
|
||||
#spring.datasource.driver-class-name=org.postgresql.Driver
|
||||
|
||||
# redis基础配置
|
||||
# 0也是默认值,表示你要操控的 Redis 上的哪个数据库
|
||||
@@ -29,11 +31,11 @@ spring.data.redis.lettuce.pool.max-wait=1ms
|
||||
spring.data.redis.lettuce.shutdown-timeout=100ms
|
||||
|
||||
#MongoDB
|
||||
spring.data.mongodb.uri=mongodb://fht:fanhuitong@139.199.77.221:27027/device_apks?authSource=admin&connectTimeoutMS=5000
|
||||
spring.mongodb.uri=mongodb://fht:fanhuitong@139.199.77.221:27027/device_apks?authSource=admin&connectTimeoutMS=5000
|
||||
|
||||
# Hibernate配置
|
||||
#spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MariaDBDialect
|
||||
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect
|
||||
#spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect
|
||||
spring.jpa.hibernate.ddl-auto=update
|
||||
spring.jpa.show-sql=true
|
||||
|
||||
|
||||
Reference in New Issue
Block a user