diff --git a/logs/web_project.log b/logs/web_project.log index 5819efd..3428219 100644 --- a/logs/web_project.log +++ b/logs/web_project.log @@ -60,3 +60,83 @@ 2025-12-23 13:56:04 [http-nio-7070-exec-9] INFO c.q.m.c.CategoryAttributeController - 接收根据分类ID获取属性列表的请求: 分类ID=2 2025-12-23 13:56:04 [http-nio-7070-exec-2] INFO c.q.m.c.CategoryAttributeController - 接收根据分类ID获取属性列表的请求: 分类ID=3 2025-12-23 13:56:04 [http-nio-7070-exec-6] INFO c.q.m.c.CategoryAttributeController - 接收根据分类ID获取属性列表的请求: 分类ID=5 +2025-12-23 13:59:35 [http-nio-7070-exec-3] INFO c.q.m.controller.MessageController - 接收分页查询消息的请求: MessagePageDto{pageNum=0, pageSize=5, articleid=5} +2025-12-23 13:59:35 [http-nio-7070-exec-3] INFO c.q.m.service.impl.MessageService - 根据分页基础信息查询所有消息: MessagePageDto{pageNum=0, pageSize=5, articleid=5} +2025-12-23 13:59:35 [http-nio-7070-exec-3] INFO c.q.m.service.impl.MessageService - 根据文章ID分页查询消息: Page 1 of 1 containing com.qf.myafterprojecy.pojo.Message instances +2025-12-23 13:59:35 [http-nio-7070-exec-3] INFO c.q.m.service.impl.MessageService - 根据文章ID查询所有子回复: 5 +2025-12-23 13:59:40 [http-nio-7070-exec-7] INFO c.q.m.controller.CategoryController - 接收获取所有分类列表的请求 +2025-12-23 13:59:40 [http-nio-7070-exec-9] INFO c.q.m.c.CategoryAttributeController - 接收根据分类ID获取属性列表的请求: 分类ID=2 +2025-12-23 13:59:40 [http-nio-7070-exec-2] INFO c.q.m.c.CategoryAttributeController - 接收根据分类ID获取属性列表的请求: 分类ID=5 +2025-12-23 13:59:40 [http-nio-7070-exec-4] INFO c.q.m.c.CategoryAttributeController - 接收根据分类ID获取属性列表的请求: 分类ID=1 +2025-12-23 13:59:40 [http-nio-7070-exec-8] INFO c.q.m.c.CategoryAttributeController - 接收根据分类ID获取属性列表的请求: 分类ID=3 +2025-12-23 13:59:46 [http-nio-7070-exec-7] INFO c.q.m.controller.CategoryController - 接收获取所有分类列表的请求 +2025-12-23 13:59:46 [http-nio-7070-exec-2] INFO c.q.m.c.CategoryAttributeController - 接收根据分类ID获取属性列表的请求: 分类ID=1 +2025-12-23 13:59:46 [http-nio-7070-exec-9] INFO c.q.m.c.CategoryAttributeController - 接收根据分类ID获取属性列表的请求: 分类ID=3 +2025-12-23 13:59:46 [http-nio-7070-exec-8] INFO c.q.m.c.CategoryAttributeController - 接收根据分类ID获取属性列表的请求: 分类ID=5 +2025-12-23 13:59:46 [http-nio-7070-exec-4] INFO c.q.m.c.CategoryAttributeController - 接收根据分类ID获取属性列表的请求: 分类ID=2 +2025-12-23 13:59:46 [http-nio-7070-exec-10] INFO c.q.m.controller.NonsenseController - 请求获取状态为1的疯言疯语内容, 分页信息: Page [pageNum=0, pageSize=5] +2025-12-23 13:59:48 [http-nio-7070-exec-7] INFO c.q.m.controller.MessageController - 接收分页查询消息的请求: MessagePageDto{pageNum=0, pageSize=5, articleid=null} +2025-12-23 13:59:48 [http-nio-7070-exec-7] INFO c.q.m.service.impl.MessageService - 根据分页基础信息查询所有消息: MessagePageDto{pageNum=0, pageSize=5, articleid=null} +2025-12-23 13:59:48 [http-nio-7070-exec-7] INFO c.q.m.service.impl.MessageService - 根据分页基础信息查询所有消息: Page request [number: 0, size 5, sort: UNSORTED] +2025-12-23 13:59:48 [http-nio-7070-exec-7] INFO c.q.m.service.impl.MessageService - 根据分页基础信息查询所有消息: Page 1 of 2 containing com.qf.myafterprojecy.pojo.Message instances +2025-12-23 13:59:48 [http-nio-7070-exec-7] INFO c.q.m.service.impl.MessageService - 根据父ID列表查询所有子回复: [233, 354, 363, 364, 366] +2025-12-23 14:00:34 [Thread-6] WARN o.a.c.loader.WebappClassLoaderBase - The web application [ROOT] appears to have started a thread named [WebProjectHikariCP housekeeper] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread: + sun.misc.Unsafe.park(Native Method) + java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215) + java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078) + java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1093) + java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809) + java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074) + java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134) + java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) + java.lang.Thread.run(Thread.java:750) +2025-12-23 14:01:20 [restartedMain] INFO c.q.m.MyAfterProjecyApplication - Starting MyAfterProjecyApplication using Java 1.8.0_461 on DESKTOP-8G5GS0I with PID 19788 (E:\MyWebProject\MyAfterProjecy\target\classes started by 30803 in E:\MyWebProject\MyAfterProjecy) +2025-12-23 14:01:20 [restartedMain] INFO c.q.m.MyAfterProjecyApplication - The following 1 profile is active: "prod" +2025-12-23 14:01:20 [restartedMain] WARN o.s.b.a.s.s.UserDetailsServiceAutoConfiguration - + +Using generated security password: 330f6769-a238-432e-a4a2-38249a51de99 + +This generated password is for development use only. Your security configuration must be updated before running your application in production. + +2025-12-23 14:01:20 [restartedMain] INFO c.q.m.MyAfterProjecyApplication - Started MyAfterProjecyApplication in 0.448 seconds (JVM running for 523.169) +2025-12-23 14:01:24 [restartedMain] INFO c.q.m.MyAfterProjecyApplication - Starting MyAfterProjecyApplication using Java 1.8.0_461 on DESKTOP-8G5GS0I with PID 19788 (E:\MyWebProject\MyAfterProjecy\target\classes started by 30803 in E:\MyWebProject\MyAfterProjecy) +2025-12-23 14:01:24 [restartedMain] INFO c.q.m.MyAfterProjecyApplication - The following 1 profile is active: "prod" +2025-12-23 14:01:25 [restartedMain] INFO c.q.m.MyAfterProjecyApplication - Started MyAfterProjecyApplication in 0.754 seconds (JVM running for 527.877) +2025-12-23 14:01:25 [restartedMain] INFO c.q.myafterprojecy.init.UserDataInit - 开始检查管理员账号... +2025-12-23 14:01:25 [restartedMain] INFO c.q.myafterprojecy.init.UserDataInit - 管理员账号 qf1121 已存在,无需创建 +2025-12-23 14:01:26 [main] INFO c.q.m.MyAfterProjecyApplicationTests - Starting MyAfterProjecyApplicationTests using Java 1.8.0_461 on DESKTOP-8G5GS0I with PID 2140 (started by 30803 in E:\MyWebProject\MyAfterProjecy) +2025-12-23 14:01:26 [main] INFO c.q.m.MyAfterProjecyApplicationTests - The following 1 profile is active: "prod" +2025-12-23 14:01:30 [main] INFO c.q.m.MyAfterProjecyApplicationTests - Started MyAfterProjecyApplicationTests in 5.135 seconds (JVM running for 6.091) +2025-12-23 14:01:30 [main] INFO c.q.myafterprojecy.init.UserDataInit - 开始检查管理员账号... +2025-12-23 14:01:31 [main] INFO c.q.myafterprojecy.init.UserDataInit - 管理员账号 qf1121 已存在,无需创建 +2025-12-23 15:07:47 [restartedMain] INFO c.q.m.MyAfterProjecyApplication - Starting MyAfterProjecyApplication using Java 1.8.0_461 on DESKTOP-8G5GS0I with PID 3876 (E:\MyWebProject\MyAfterProjecy\target\classes started by 30803 in E:\MyWebProject\MyAfterProjecy) +2025-12-23 15:07:47 [restartedMain] INFO c.q.m.MyAfterProjecyApplication - The following 1 profile is active: "prod" +2025-12-23 15:07:52 [restartedMain] INFO c.q.m.MyAfterProjecyApplication - Started MyAfterProjecyApplication in 5.216 seconds (JVM running for 6.219) +2025-12-23 15:07:52 [restartedMain] INFO c.q.myafterprojecy.init.UserDataInit - 开始检查管理员账号... +2025-12-23 15:07:52 [restartedMain] INFO c.q.myafterprojecy.init.UserDataInit - 管理员账号 qf1121 已存在,无需创建 +2025-12-23 15:07:53 [http-nio-7070-exec-2] INFO c.q.m.c.CategoryAttributeController - 接收获取分类属性数量的请求 +2025-12-23 15:07:53 [http-nio-7070-exec-1] INFO c.q.m.controller.CategoryController - 接收获取所有分类列表的请求 +2025-12-23 15:07:54 [http-nio-7070-exec-8] INFO c.q.m.c.CategoryAttributeController - 接收根据分类ID获取属性列表的请求: 分类ID=1 +2025-12-23 15:07:54 [http-nio-7070-exec-10] INFO c.q.m.c.CategoryAttributeController - 接收根据分类ID获取属性列表的请求: 分类ID=2 +2025-12-23 15:07:54 [http-nio-7070-exec-2] INFO c.q.m.c.CategoryAttributeController - 接收根据分类ID获取属性列表的请求: 分类ID=5 +2025-12-23 15:07:54 [http-nio-7070-exec-9] INFO c.q.m.c.CategoryAttributeController - 接收根据分类ID获取属性列表的请求: 分类ID=3 +2025-12-23 15:07:58 [http-nio-7070-exec-1] INFO c.q.m.controller.CategoryController - 接收获取所有分类列表的请求 +2025-12-23 15:07:58 [http-nio-7070-exec-5] INFO c.q.m.c.CategoryAttributeController - 接收根据分类ID获取属性列表的请求: 分类ID=3 +2025-12-23 15:07:58 [http-nio-7070-exec-4] INFO c.q.m.c.CategoryAttributeController - 接收根据分类ID获取属性列表的请求: 分类ID=2 +2025-12-23 15:07:58 [http-nio-7070-exec-6] INFO c.q.m.c.CategoryAttributeController - 接收根据分类ID获取属性列表的请求: 分类ID=1 +2025-12-23 15:07:58 [http-nio-7070-exec-7] INFO c.q.m.c.CategoryAttributeController - 接收根据分类ID获取属性列表的请求: 分类ID=5 +2025-12-23 15:08:00 [http-nio-7070-exec-1] INFO c.q.m.controller.CategoryController - 接收获取所有分类列表的请求 +2025-12-23 15:08:00 [http-nio-7070-exec-5] INFO c.q.m.c.CategoryAttributeController - 接收根据分类ID获取属性列表的请求: 分类ID=1 +2025-12-23 15:08:01 [http-nio-7070-exec-6] INFO c.q.m.c.CategoryAttributeController - 接收根据分类ID获取属性列表的请求: 分类ID=2 +2025-12-23 15:08:01 [http-nio-7070-exec-4] INFO c.q.m.c.CategoryAttributeController - 接收根据分类ID获取属性列表的请求: 分类ID=5 +2025-12-23 15:08:01 [http-nio-7070-exec-7] INFO c.q.m.c.CategoryAttributeController - 接收根据分类ID获取属性列表的请求: 分类ID=3 +2025-12-23 15:08:02 [http-nio-7070-exec-1] INFO c.q.m.controller.CategoryController - 接收获取所有分类列表的请求 +2025-12-23 15:08:02 [http-nio-7070-exec-5] INFO c.q.m.c.CategoryAttributeController - 接收根据分类ID获取属性列表的请求: 分类ID=1 +2025-12-23 15:08:02 [http-nio-7070-exec-6] INFO c.q.m.c.CategoryAttributeController - 接收根据分类ID获取属性列表的请求: 分类ID=2 +2025-12-23 15:08:02 [http-nio-7070-exec-7] INFO c.q.m.c.CategoryAttributeController - 接收根据分类ID获取属性列表的请求: 分类ID=3 +2025-12-23 15:08:02 [http-nio-7070-exec-4] INFO c.q.m.c.CategoryAttributeController - 接收根据分类ID获取属性列表的请求: 分类ID=5 +2025-12-23 15:08:03 [http-nio-7070-exec-1] INFO c.q.m.controller.CategoryController - 接收获取所有分类列表的请求 +2025-12-23 15:08:04 [http-nio-7070-exec-5] INFO c.q.m.c.CategoryAttributeController - 接收根据分类ID获取属性列表的请求: 分类ID=1 +2025-12-23 15:08:04 [http-nio-7070-exec-4] INFO c.q.m.c.CategoryAttributeController - 接收根据分类ID获取属性列表的请求: 分类ID=2 +2025-12-23 15:08:04 [http-nio-7070-exec-7] INFO c.q.m.c.CategoryAttributeController - 接收根据分类ID获取属性列表的请求: 分类ID=5 +2025-12-23 15:08:04 [http-nio-7070-exec-6] INFO c.q.m.c.CategoryAttributeController - 接收根据分类ID获取属性列表的请求: 分类ID=3 diff --git a/src/main/java/com/qf/myafterprojecy/config/SecurityConfig.java b/src/main/java/com/qf/myafterprojecy/config/SecurityConfig.java index 6a7fecd..83e5b15 100644 --- a/src/main/java/com/qf/myafterprojecy/config/SecurityConfig.java +++ b/src/main/java/com/qf/myafterprojecy/config/SecurityConfig.java @@ -54,14 +54,15 @@ public class SecurityConfig { @Bean public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { http - // 鍚敤CORS鏀寔锛岀‘淇濅笌CorsConfig涓厤缃殑杩囨护鍣ㄩ厤鍚堝伐浣 - .cors().and() // 绂佺敤CSRF淇濇姢锛堝浜嶢PI鏈嶅姟閫氬父涓嶉渶瑕侊級 .csrf().disable() + // 浣跨敤鑷畾涔夌殑CORS杩囨护鍣紝涓嶄娇鐢ㄩ粯璁ょ殑cors()閰嶇疆 // 閰嶇疆URL璁块棶鏉冮檺 .authorizeRequests() // 鍏佽鍏紑璁块棶鐨勮矾寰 // 鐧诲綍鍜岃璇佺浉鍏崇鐐瑰簲璇ュ叏閮ㄥ叕寮 + + .antMatchers(HttpMethod.POST,"/api/auth/**").permitAll() // 鏂囩珷娴忚閲忓鍔犳帴鍙e叕寮 .antMatchers(HttpMethod.POST,"/api/articles/view/**").permitAll() @@ -86,13 +87,6 @@ public class SecurityConfig { // 纭繚OPTIONS璇锋眰鑳藉閫氳繃锛屽鐞嗛妫璇锋眰 .exceptionHandling() .authenticationEntryPoint((request, response, authException) -> { - // 璁剧疆CORS澶翠俊鎭 - response.setHeader("Access-Control-Allow-Origin", "*"); - response.setHeader("Access-Control-Allow-Credentials", "true"); - response.setHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS, PATCH"); - response.setHeader("Access-Control-Allow-Headers", "*"); - response.setHeader("Access-Control-Max-Age", "3600"); - // 濡傛灉鏄妫璇锋眰锛岀洿鎺ヨ繑鍥200 if ("OPTIONS".equalsIgnoreCase(request.getMethod())) { response.setStatus(HttpServletResponse.SC_OK); @@ -120,10 +114,6 @@ public class SecurityConfig { // 閰嶇疆璁块棶鎷掔粷澶勭悊鍣 http.exceptionHandling() .accessDeniedHandler((request, response, accessDeniedException) -> { - // 璁剧疆CORS澶翠俊鎭 - response.setHeader("Access-Control-Allow-Origin", "*"); - response.setHeader("Access-Control-Allow-Credentials", "true"); - // 鏃犳潈闄愬鐞 response.setStatus(HttpServletResponse.SC_FORBIDDEN); response.setContentType("application/json;charset=UTF-8"); diff --git a/src/main/resources/application-prod.properties b/src/main/resources/application-prod.properties index 6afba18..18f7117 100644 --- a/src/main/resources/application-prod.properties +++ b/src/main/resources/application-prod.properties @@ -9,13 +9,9 @@ server.port=7070 # ==================================================================== # 鏁版嵁搴撲笌JPA閰嶇疆 - 鐢熶骇鐢 # ==================================================================== -# spring.datasource.url=${DB_URL:jdbc:mysql://mysql:3306/webproject?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai} -# spring.datasource.username=${DB_USERNAME:root} -# spring.datasource.password=${DB_PASSWORD:root} -# spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver -spring.datasource.url=jdbc:mysql://localhost:3306/webproject?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&createDatabaseIfNotExist=true&allowPublicKeyRetrieval=true -spring.datasource.username=root -spring.datasource.password=123456 +spring.datasource.url=${DB_URL:jdbc:mysql://mysql:3306/webproject?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai} +spring.datasource.username=${DB_USERNAME:root} +spring.datasource.password=${DB_PASSWORD:root} spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver # 鏁版嵁搴撹繛鎺ユ睜閰嶇疆锛堢敓浜х幆澧冧紭鍖栫増锛 spring.datasource.hikari.maximum-pool-size=20 @@ -50,8 +46,7 @@ jwt.token-prefix=Bearer # 瀹夊叏涓嶤ORS閰嶇疆 - 鐢熶骇鐢 # ==================================================================== # CORS閰嶇疆锛堢敓浜х幆澧冮檺鍒朵负鍏蜂綋鍩熷悕锛 -# cors.allowed-origins=http://qf1121.top,https://qf1121.top,http://www.qf1121.top,https://www.qf1121.top -cors.allowed-origins=http://localhost:3000,http://localhost:8080,http://localhost:5173 +cors.allowed-origins=http://qf1121.top,https://qf1121.top,http://www.qf1121.top,https://www.qf1121.top cors.allowed-methods=GET,POST,PUT,DELETE,OPTIONS cors.allowed-headers=* cors.allow-credentials=true diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 4f4bea9..289c1d6 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -3,7 +3,7 @@ # ==================================================================== # 鐜婵娲婚厤缃 # 璇存槑锛氶粯璁ゆ縺娲诲紑鍙戠幆澧冿紝鐢熶骇鐜閮ㄧ讲鏃跺簲閫氳繃鍛戒护琛屽弬鏁版垨鐜鍙橀噺瑕嗙洊 -spring.profiles.active=prod +spring.profiles.active=dev # 搴旂敤鍚嶇О锛堥氱敤閰嶇疆锛 spring.application.name=web_project