diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..639900d --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..94f0303 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/spring_study.iml b/.idea/spring_study.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/spring_study.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..d91cefa --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + 1681362947777 + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index b833330..ae0a130 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -### 学习使用Spring和SpringBoot +### 学习使用Spring和SpringBoot test diff --git a/SpringDataJPA/logs/spring-info.log b/SpringDataJPA/logs/spring-info.log index 1a5fe6f..973e9b4 100644 --- a/SpringDataJPA/logs/spring-info.log +++ b/SpringDataJPA/logs/spring-info.log @@ -1,108 +1,661 @@ -2023-03-10 00:22:33.004 INFO 17776 --- [restartedMain] c.b.s.SpringDataJpaApplication : Starting SpringDataJpaApplication using Java 1.8.0_342 on DESKTOP-G5S5LHL with PID 17776 (D:\spring_study\SpringDataJPA\target\classes started by 15270 in D:\spring_study\SpringDataJPA) -2023-03-10 00:22:33.005 INFO 17776 --- [restartedMain] c.b.s.SpringDataJpaApplication : No active profile set, falling back to 1 default profile: "default" -2023-03-10 00:22:33.038 INFO 17776 --- [restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable -2023-03-10 00:22:33.039 INFO 17776 --- [restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG' -2023-03-10 00:22:33.483 INFO 17776 --- [restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode. -2023-03-10 00:22:33.523 INFO 17776 --- [restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 33 ms. Found 1 JPA repository interfaces. -2023-03-10 00:22:33.928 INFO 17776 --- [restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) -2023-03-10 00:22:33.929 INFO 17776 --- [restartedMain] o.a.catalina.core.AprLifecycleListener : Loaded Apache Tomcat Native library [1.2.33] using APR version [1.7.0]. -2023-03-10 00:22:33.929 INFO 17776 --- [restartedMain] o.a.catalina.core.AprLifecycleListener : APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true], UDS [true]. -2023-03-10 00:22:33.929 INFO 17776 --- [restartedMain] o.a.catalina.core.AprLifecycleListener : APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true] -2023-03-10 00:22:33.932 INFO 17776 --- [restartedMain] o.a.catalina.core.AprLifecycleListener : OpenSSL successfully initialized [OpenSSL 1.1.1o 3 May 2022] -2023-03-10 00:22:33.941 INFO 17776 --- [restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat] -2023-03-10 00:22:33.941 INFO 17776 --- [restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.69] -2023-03-10 00:22:34.016 INFO 17776 --- [restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext -2023-03-10 00:22:34.016 INFO 17776 --- [restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 977 ms -2023-03-10 00:22:34.124 INFO 17776 --- [restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default] -2023-03-10 00:22:34.160 INFO 17776 --- [restartedMain] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.6.14.Final -2023-03-10 00:22:34.322 INFO 17776 --- [restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final} -2023-03-10 00:22:34.398 INFO 17776 --- [restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting... -2023-03-10 00:22:34.615 INFO 17776 --- [restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed. -2023-03-10 00:22:34.629 INFO 17776 --- [restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL8Dialect -2023-03-10 00:22:35.011 INFO 17776 --- [restartedMain] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform] -2023-03-10 00:22:35.017 INFO 17776 --- [restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default' -2023-03-10 00:22:35.366 WARN 17776 --- [restartedMain] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning -2023-03-10 00:22:35.467 INFO 17776 --- [restartedMain] o.s.s.web.DefaultSecurityFilterChain : Will secure any request with [org.springframework.security.web.session.DisableEncodeUrlFilter@4dcdcaf9, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@432e404, org.springframework.security.web.context.SecurityContextPersistenceFilter@2e86ec29, org.springframework.security.web.header.HeaderWriterFilter@60f25f4a, org.springframework.security.web.authentication.logout.LogoutFilter@435a5b71, cc.bnblogs.springdatajpa.config.filter.JwtAuthenticationTokenFilter@72bef81f, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@16c25b67, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@464f7268, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@4951416d, org.springframework.security.web.session.SessionManagementFilter@46235d83, org.springframework.security.web.access.ExceptionTranslationFilter@7c351bae, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@33cdae31] -2023-03-10 00:22:35.832 INFO 17776 --- [restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729 -2023-03-10 00:22:35.859 INFO 17776 --- [restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path '' -2023-03-10 00:22:35.868 INFO 17776 --- [restartedMain] c.b.s.SpringDataJpaApplication : Started SpringDataJpaApplication in 3.214 seconds (JVM running for 4.144) -2023-03-10 00:22:41.421 INFO 17776 --- [SpringApplicationShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default' -2023-03-10 00:22:41.423 INFO 17776 --- [SpringApplicationShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated... -2023-03-10 00:22:41.427 INFO 17776 --- [SpringApplicationShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed. -2023-03-10 00:42:53.221 INFO 15980 --- [main] c.b.s.SpringDataJpaApplicationTests : Starting SpringDataJpaApplicationTests using Java 1.8.0_342 on DESKTOP-G5S5LHL with PID 15980 (started by 15270 in D:\spring_study\SpringDataJPA) -2023-03-10 00:42:53.222 INFO 15980 --- [main] c.b.s.SpringDataJpaApplicationTests : No active profile set, falling back to 1 default profile: "default" -2023-03-10 00:42:53.883 INFO 15980 --- [main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode. -2023-03-10 00:42:53.942 INFO 15980 --- [main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 49 ms. Found 1 JPA repository interfaces. -2023-03-10 00:42:54.545 INFO 15980 --- [main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default] -2023-03-10 00:42:54.591 INFO 15980 --- [main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.6.14.Final -2023-03-10 00:42:54.772 INFO 15980 --- [main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final} -2023-03-10 00:42:55.238 INFO 15980 --- [main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting... -2023-03-10 00:42:55.528 INFO 15980 --- [main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed. -2023-03-10 00:42:55.558 INFO 15980 --- [main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL8Dialect -2023-03-10 00:42:56.123 INFO 15980 --- [main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform] -2023-03-10 00:42:56.131 INFO 15980 --- [main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default' -2023-03-10 00:42:56.186 WARN 15980 --- [main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning -2023-03-10 00:42:57.017 INFO 15980 --- [main] o.s.s.web.DefaultSecurityFilterChain : Will secure any request with [org.springframework.security.web.session.DisableEncodeUrlFilter@4e8afdad, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@79b8ecb, org.springframework.security.web.context.SecurityContextPersistenceFilter@4348fa35, org.springframework.security.web.header.HeaderWriterFilter@30704f85, org.springframework.security.web.authentication.logout.LogoutFilter@5abbb273, cc.bnblogs.springdatajpa.config.filter.JwtAuthenticationTokenFilter@79b7c350, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@38cb1606, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@56872fcb, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@3722f39d, org.springframework.security.web.session.SessionManagementFilter@1029cf9, org.springframework.security.web.access.ExceptionTranslationFilter@6abe62bb, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@4d065e1a] -2023-03-10 00:42:57.730 INFO 15980 --- [main] c.b.s.SpringDataJpaApplicationTests : Started SpringDataJpaApplicationTests in 4.842 seconds (JVM running for 5.87) -2023-03-10 00:42:57.814 INFO 15980 --- [main] c.b.s.SpringDataJpaApplicationTests : Info 日志... -2023-03-10 00:42:57.814 WARN 15980 --- [main] c.b.s.SpringDataJpaApplicationTests : Warn 日志... -2023-03-10 00:42:57.815 ERROR 15980 --- [main] c.b.s.SpringDataJpaApplicationTests : Error 日志... -2023-03-10 00:42:57.831 INFO 15980 --- [SpringApplicationShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default' -2023-03-10 00:42:57.833 INFO 15980 --- [SpringApplicationShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated... -2023-03-10 00:42:57.838 INFO 15980 --- [SpringApplicationShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed. -2023-03-10 00:44:48.236 INFO 13664 --- [main] c.b.s.SpringDataJpaApplicationTests : Starting SpringDataJpaApplicationTests using Java 1.8.0_342 on DESKTOP-G5S5LHL with PID 13664 (started by 15270 in D:\spring_study\SpringDataJPA) -2023-03-10 00:44:48.238 INFO 13664 --- [main] c.b.s.SpringDataJpaApplicationTests : No active profile set, falling back to 1 default profile: "default" -2023-03-10 00:44:48.831 INFO 13664 --- [main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode. -2023-03-10 00:44:48.885 INFO 13664 --- [main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 48 ms. Found 1 JPA repository interfaces. -2023-03-10 00:44:49.438 INFO 13664 --- [main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default] -2023-03-10 00:44:49.485 INFO 13664 --- [main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.6.14.Final -2023-03-10 00:44:49.667 INFO 13664 --- [main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final} -2023-03-10 00:44:50.148 INFO 13664 --- [main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting... -2023-03-10 00:44:50.447 INFO 13664 --- [main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed. -2023-03-10 00:44:50.478 INFO 13664 --- [main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL8Dialect -2023-03-10 00:44:51.051 INFO 13664 --- [main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform] -2023-03-10 00:44:51.058 INFO 13664 --- [main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default' -2023-03-10 00:44:51.118 WARN 13664 --- [main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning -2023-03-10 00:44:51.972 INFO 13664 --- [main] o.s.s.web.DefaultSecurityFilterChain : Will secure any request with [org.springframework.security.web.session.DisableEncodeUrlFilter@3722f39d, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@4ec8d9b2, org.springframework.security.web.context.SecurityContextPersistenceFilter@61c4cebd, org.springframework.security.web.header.HeaderWriterFilter@1de12397, org.springframework.security.web.authentication.logout.LogoutFilter@445058e8, cc.bnblogs.springdatajpa.config.filter.JwtAuthenticationTokenFilter@4cd7e993, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@716ae973, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@5d3b6585, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@57b63253, org.springframework.security.web.session.SessionManagementFilter@4348fa35, org.springframework.security.web.access.ExceptionTranslationFilter@29c25bbc, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@6dbbdf92] -2023-03-10 00:44:52.762 INFO 13664 --- [main] c.b.s.SpringDataJpaApplicationTests : Started SpringDataJpaApplicationTests in 4.9 seconds (JVM running for 5.956) -2023-03-10 00:44:52.768 INFO 13664 --- [SpringApplicationShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default' -2023-03-10 00:44:52.770 INFO 13664 --- [SpringApplicationShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated... -2023-03-10 00:44:52.775 INFO 13664 --- [SpringApplicationShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed. -2023-03-10 00:44:59.262 INFO 4060 --- [restartedMain] c.b.s.SpringDataJpaApplication : Starting SpringDataJpaApplication using Java 1.8.0_342 on DESKTOP-G5S5LHL with PID 4060 (D:\spring_study\SpringDataJPA\target\classes started by 15270 in D:\spring_study\SpringDataJPA) -2023-03-10 00:44:59.263 INFO 4060 --- [restartedMain] c.b.s.SpringDataJpaApplication : No active profile set, falling back to 1 default profile: "default" -2023-03-10 00:44:59.297 INFO 4060 --- [restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable -2023-03-10 00:44:59.297 INFO 4060 --- [restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG' -2023-03-10 00:44:59.767 INFO 4060 --- [restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode. -2023-03-10 00:44:59.810 INFO 4060 --- [restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 35 ms. Found 1 JPA repository interfaces. -2023-03-10 00:45:00.211 INFO 4060 --- [restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) -2023-03-10 00:45:00.212 INFO 4060 --- [restartedMain] o.a.catalina.core.AprLifecycleListener : Loaded Apache Tomcat Native library [1.2.33] using APR version [1.7.0]. -2023-03-10 00:45:00.212 INFO 4060 --- [restartedMain] o.a.catalina.core.AprLifecycleListener : APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true], UDS [true]. -2023-03-10 00:45:00.213 INFO 4060 --- [restartedMain] o.a.catalina.core.AprLifecycleListener : APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true] -2023-03-10 00:45:00.215 INFO 4060 --- [restartedMain] o.a.catalina.core.AprLifecycleListener : OpenSSL successfully initialized [OpenSSL 1.1.1o 3 May 2022] -2023-03-10 00:45:00.221 INFO 4060 --- [restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat] -2023-03-10 00:45:00.221 INFO 4060 --- [restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.69] -2023-03-10 00:45:00.287 INFO 4060 --- [restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext -2023-03-10 00:45:00.287 INFO 4060 --- [restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 989 ms -2023-03-10 00:45:00.396 INFO 4060 --- [restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default] -2023-03-10 00:45:00.427 INFO 4060 --- [restartedMain] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.6.14.Final -2023-03-10 00:45:00.541 INFO 4060 --- [restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final} -2023-03-10 00:45:00.640 INFO 4060 --- [restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting... -2023-03-10 00:45:00.852 INFO 4060 --- [restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed. -2023-03-10 00:45:00.866 INFO 4060 --- [restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL8Dialect -2023-03-10 00:45:01.298 INFO 4060 --- [restartedMain] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform] -2023-03-10 00:45:01.304 INFO 4060 --- [restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default' -2023-03-10 00:45:01.732 WARN 4060 --- [restartedMain] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning -2023-03-10 00:45:01.848 INFO 4060 --- [restartedMain] o.s.s.web.DefaultSecurityFilterChain : Will secure any request with [org.springframework.security.web.session.DisableEncodeUrlFilter@4951416d, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@35ce8515, org.springframework.security.web.context.SecurityContextPersistenceFilter@16c25b67, org.springframework.security.web.header.HeaderWriterFilter@325452bc, org.springframework.security.web.authentication.logout.LogoutFilter@4c6e832, cc.bnblogs.springdatajpa.config.filter.JwtAuthenticationTokenFilter@6359aed6, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@6dfd384d, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@29446ba2, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@16771b57, org.springframework.security.web.session.SessionManagementFilter@2e86ec29, org.springframework.security.web.access.ExceptionTranslationFilter@7dee01bd, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@1f618dd7] -2023-03-10 00:45:02.241 INFO 4060 --- [restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729 -2023-03-10 00:45:02.267 INFO 4060 --- [restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path '' -2023-03-10 00:45:02.276 INFO 4060 --- [restartedMain] c.b.s.SpringDataJpaApplication : Started SpringDataJpaApplication in 3.366 seconds (JVM running for 4.299) -2023-03-10 00:45:17.005 INFO 4060 --- [http-nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet' -2023-03-10 00:45:17.005 INFO 4060 --- [http-nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet' -2023-03-10 00:45:17.006 INFO 4060 --- [http-nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 1 ms -2023-03-10 00:45:17.109 WARN 4060 --- [http-nio-8080-exec-1] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'POST' not supported] -2023-03-10 00:45:19.820 INFO 4060 --- [http-nio-8080-exec-4] c.b.s.controller.DemoController : Info 日志... -2023-03-10 00:45:19.820 WARN 4060 --- [http-nio-8080-exec-4] c.b.s.controller.DemoController : Warn 日志... -2023-03-10 00:45:19.820 ERROR 4060 --- [http-nio-8080-exec-4] c.b.s.controller.DemoController : Error 日志... -2023-03-10 00:45:35.166 INFO 4060 --- [SpringApplicationShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default' -2023-03-10 00:45:35.169 INFO 4060 --- [SpringApplicationShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated... -2023-03-10 00:45:35.173 INFO 4060 --- [SpringApplicationShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed. +2023-04-13 14:12:02.071 INFO 15424 --- [restartedMain] c.b.s.SpringDataJpaApplication : Starting SpringDataJpaApplication using Java 1.8.0_201 on DESKTOP-AH1VP76 with PID 15424 (D:\spring_study\SpringDataJPA\target\classes started by zfp in D:\spring_study\SpringDataJPA) +2023-04-13 14:12:02.075 INFO 15424 --- [restartedMain] c.b.s.SpringDataJpaApplication : No active profile set, falling back to 1 default profile: "default" +2023-04-13 14:12:02.108 INFO 15424 --- [restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable +2023-04-13 14:12:02.108 INFO 15424 --- [restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG' +2023-04-13 14:12:02.589 INFO 15424 --- [restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode. +2023-04-13 14:12:02.629 INFO 15424 --- [restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 33 ms. Found 1 JPA repository interfaces. +2023-04-13 14:12:03.079 INFO 15424 --- [restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) +2023-04-13 14:12:03.091 INFO 15424 --- [restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat] +2023-04-13 14:12:03.091 INFO 15424 --- [restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.69] +2023-04-13 14:12:03.178 INFO 15424 --- [restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext +2023-04-13 14:12:03.178 INFO 15424 --- [restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1069 ms +2023-04-13 14:12:03.328 INFO 15424 --- [restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default] +2023-04-13 14:12:03.363 INFO 15424 --- [restartedMain] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.6.14.Final +2023-04-13 14:12:03.506 INFO 15424 --- [restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final} +2023-04-13 14:12:03.575 INFO 15424 --- [restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting... +2023-04-13 14:12:03.933 INFO 15424 --- [restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed. +2023-04-13 14:12:03.946 INFO 15424 --- [restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL8Dialect +2023-04-13 14:12:04.322 INFO 15424 --- [restartedMain] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform] +2023-04-13 14:12:04.328 INFO 15424 --- [restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default' +2023-04-13 14:12:04.683 WARN 15424 --- [restartedMain] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning +2023-04-13 14:12:04.784 INFO 15424 --- [restartedMain] o.s.s.web.DefaultSecurityFilterChain : Will secure any request with [org.springframework.security.web.session.DisableEncodeUrlFilter@2273f5ee, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@6bd92e8a, org.springframework.security.web.context.SecurityContextPersistenceFilter@7b6b3972, org.springframework.security.web.header.HeaderWriterFilter@1843d125, org.springframework.security.web.authentication.logout.LogoutFilter@40bfda3d, cc.bnblogs.springdatajpa.config.filter.JwtAuthenticationTokenFilter@d85f2d6, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@5e0ad863, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@38f5e18e, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@10696822, org.springframework.security.web.session.SessionManagementFilter@1b2fcb92, org.springframework.security.web.access.ExceptionTranslationFilter@64311e64, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@bd704ea] +2023-04-13 14:12:05.015 INFO 15424 --- [restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729 +2023-04-13 14:12:05.154 INFO 15424 --- [restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path '' +2023-04-13 14:12:05.162 INFO 15424 --- [restartedMain] c.b.s.SpringDataJpaApplication : Started SpringDataJpaApplication in 3.412 seconds (JVM running for 4.155) +2023-04-13 14:12:23.137 INFO 15424 --- [http-nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet' +2023-04-13 14:12:23.137 INFO 15424 --- [http-nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet' +2023-04-13 14:12:23.140 INFO 15424 --- [http-nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 3 ms +2023-04-13 14:14:19.694 ERROR 15424 --- [http-nio-8080-exec-3] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception + +org.springframework.security.web.firewall.RequestRejectedException: The request was rejected because the URL contained a potentially malicious String "//" + at org.springframework.security.web.firewall.StrictHttpFirewall.rejectedBlocklistedUrls(StrictHttpFirewall.java:535) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.firewall.StrictHttpFirewall.getFirewalledRequest(StrictHttpFirewall.java:505) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:206) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:186) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:354) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:267) ~[spring-web-5.3.24.jar:5.3.24] + at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.24.jar:5.3.24] + at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.24.jar:5.3.24] + at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.24.jar:5.3.24] + at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:177) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:891) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1784) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.69.jar:9.0.69] + at java.lang.Thread.run(Thread.java:748) [na:1.8.0_201] + +2023-04-13 14:14:24.734 WARN 15424 --- [http-nio-8080-exec-9] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'GET' not supported] +2023-04-13 14:16:28.583 WARN 15424 --- [http-nio-8080-exec-2] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'GET' not supported] +2023-04-13 14:22:31.209 ERROR 15424 --- [http-nio-8080-exec-10] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception + +java.lang.RuntimeException: io.jsonwebtoken.security.SignatureException: JWT signature does not match locally computed signature. JWT validity cannot be asserted and should not be trusted. + at cc.bnblogs.springdatajpa.config.filter.JwtAuthenticationTokenFilter.doFilterInternal(JwtAuthenticationTokenFilter.java:43) ~[classes/:na] + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:103) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:89) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:90) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:75) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:112) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:82) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:55) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.session.DisableEncodeUrlFilter.doFilterInternal(DisableEncodeUrlFilter.java:42) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:221) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:186) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:354) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:267) ~[spring-web-5.3.24.jar:5.3.24] + at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.24.jar:5.3.24] + at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.24.jar:5.3.24] + at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.24.jar:5.3.24] + at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:177) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:891) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1784) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.69.jar:9.0.69] + at java.lang.Thread.run(Thread.java:748) [na:1.8.0_201] +Caused by: io.jsonwebtoken.security.SignatureException: JWT signature does not match locally computed signature. JWT validity cannot be asserted and should not be trusted. + at io.jsonwebtoken.impl.DefaultJwtParser.parse(DefaultJwtParser.java:399) ~[jjwt-impl-0.11.5.jar:0.11.5] + at io.jsonwebtoken.impl.DefaultJwtParser.parse(DefaultJwtParser.java:529) ~[jjwt-impl-0.11.5.jar:0.11.5] + at io.jsonwebtoken.impl.DefaultJwtParser.parseClaimsJws(DefaultJwtParser.java:589) ~[jjwt-impl-0.11.5.jar:0.11.5] + at io.jsonwebtoken.impl.ImmutableJwtParser.parseClaimsJws(ImmutableJwtParser.java:173) ~[jjwt-impl-0.11.5.jar:0.11.5] + at cc.bnblogs.springdatajpa.utils.JwtUtil.parseJWT(JwtUtil.java:65) ~[classes/:na] + at cc.bnblogs.springdatajpa.config.filter.JwtAuthenticationTokenFilter.doFilterInternal(JwtAuthenticationTokenFilter.java:40) ~[classes/:na] + ... 52 common frames omitted + +2023-04-13 14:22:40.831 ERROR 15424 --- [http-nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception + +java.lang.RuntimeException: io.jsonwebtoken.security.SignatureException: JWT signature does not match locally computed signature. JWT validity cannot be asserted and should not be trusted. + at cc.bnblogs.springdatajpa.config.filter.JwtAuthenticationTokenFilter.doFilterInternal(JwtAuthenticationTokenFilter.java:43) ~[classes/:na] + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:103) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:89) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:90) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:75) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:112) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:82) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:55) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.session.DisableEncodeUrlFilter.doFilterInternal(DisableEncodeUrlFilter.java:42) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:221) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:186) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:354) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:267) ~[spring-web-5.3.24.jar:5.3.24] + at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.24.jar:5.3.24] + at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.24.jar:5.3.24] + at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.24.jar:5.3.24] + at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:177) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:891) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1784) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.69.jar:9.0.69] + at java.lang.Thread.run(Thread.java:748) [na:1.8.0_201] +Caused by: io.jsonwebtoken.security.SignatureException: JWT signature does not match locally computed signature. JWT validity cannot be asserted and should not be trusted. + at io.jsonwebtoken.impl.DefaultJwtParser.parse(DefaultJwtParser.java:399) ~[jjwt-impl-0.11.5.jar:0.11.5] + at io.jsonwebtoken.impl.DefaultJwtParser.parse(DefaultJwtParser.java:529) ~[jjwt-impl-0.11.5.jar:0.11.5] + at io.jsonwebtoken.impl.DefaultJwtParser.parseClaimsJws(DefaultJwtParser.java:589) ~[jjwt-impl-0.11.5.jar:0.11.5] + at io.jsonwebtoken.impl.ImmutableJwtParser.parseClaimsJws(ImmutableJwtParser.java:173) ~[jjwt-impl-0.11.5.jar:0.11.5] + at cc.bnblogs.springdatajpa.utils.JwtUtil.parseJWT(JwtUtil.java:65) ~[classes/:na] + at cc.bnblogs.springdatajpa.config.filter.JwtAuthenticationTokenFilter.doFilterInternal(JwtAuthenticationTokenFilter.java:40) ~[classes/:na] + ... 52 common frames omitted + +2023-04-13 14:24:50.139 ERROR 15424 --- [http-nio-8080-exec-10] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception + +java.lang.RuntimeException: io.jsonwebtoken.security.SignatureException: JWT signature does not match locally computed signature. JWT validity cannot be asserted and should not be trusted. + at cc.bnblogs.springdatajpa.config.filter.JwtAuthenticationTokenFilter.doFilterInternal(JwtAuthenticationTokenFilter.java:43) ~[classes/:na] + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:103) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:89) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:90) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:75) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:112) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:82) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:55) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.session.DisableEncodeUrlFilter.doFilterInternal(DisableEncodeUrlFilter.java:42) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:221) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:186) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:354) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:267) ~[spring-web-5.3.24.jar:5.3.24] + at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.24.jar:5.3.24] + at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.24.jar:5.3.24] + at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.24.jar:5.3.24] + at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:177) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:891) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1784) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.69.jar:9.0.69] + at java.lang.Thread.run(Thread.java:748) [na:1.8.0_201] +Caused by: io.jsonwebtoken.security.SignatureException: JWT signature does not match locally computed signature. JWT validity cannot be asserted and should not be trusted. + at io.jsonwebtoken.impl.DefaultJwtParser.parse(DefaultJwtParser.java:399) ~[jjwt-impl-0.11.5.jar:0.11.5] + at io.jsonwebtoken.impl.DefaultJwtParser.parse(DefaultJwtParser.java:529) ~[jjwt-impl-0.11.5.jar:0.11.5] + at io.jsonwebtoken.impl.DefaultJwtParser.parseClaimsJws(DefaultJwtParser.java:589) ~[jjwt-impl-0.11.5.jar:0.11.5] + at io.jsonwebtoken.impl.ImmutableJwtParser.parseClaimsJws(ImmutableJwtParser.java:173) ~[jjwt-impl-0.11.5.jar:0.11.5] + at cc.bnblogs.springdatajpa.utils.JwtUtil.parseJWT(JwtUtil.java:65) ~[classes/:na] + at cc.bnblogs.springdatajpa.config.filter.JwtAuthenticationTokenFilter.doFilterInternal(JwtAuthenticationTokenFilter.java:40) ~[classes/:na] + ... 52 common frames omitted + +2023-04-13 14:24:51.772 ERROR 15424 --- [http-nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception + +java.lang.RuntimeException: io.jsonwebtoken.security.SignatureException: JWT signature does not match locally computed signature. JWT validity cannot be asserted and should not be trusted. + at cc.bnblogs.springdatajpa.config.filter.JwtAuthenticationTokenFilter.doFilterInternal(JwtAuthenticationTokenFilter.java:43) ~[classes/:na] + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:103) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:89) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:90) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:75) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:112) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:82) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:55) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.session.DisableEncodeUrlFilter.doFilterInternal(DisableEncodeUrlFilter.java:42) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:221) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:186) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:354) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:267) ~[spring-web-5.3.24.jar:5.3.24] + at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.24.jar:5.3.24] + at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.24.jar:5.3.24] + at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.24.jar:5.3.24] + at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:177) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:891) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1784) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.69.jar:9.0.69] + at java.lang.Thread.run(Thread.java:748) [na:1.8.0_201] +Caused by: io.jsonwebtoken.security.SignatureException: JWT signature does not match locally computed signature. JWT validity cannot be asserted and should not be trusted. + at io.jsonwebtoken.impl.DefaultJwtParser.parse(DefaultJwtParser.java:399) ~[jjwt-impl-0.11.5.jar:0.11.5] + at io.jsonwebtoken.impl.DefaultJwtParser.parse(DefaultJwtParser.java:529) ~[jjwt-impl-0.11.5.jar:0.11.5] + at io.jsonwebtoken.impl.DefaultJwtParser.parseClaimsJws(DefaultJwtParser.java:589) ~[jjwt-impl-0.11.5.jar:0.11.5] + at io.jsonwebtoken.impl.ImmutableJwtParser.parseClaimsJws(ImmutableJwtParser.java:173) ~[jjwt-impl-0.11.5.jar:0.11.5] + at cc.bnblogs.springdatajpa.utils.JwtUtil.parseJWT(JwtUtil.java:65) ~[classes/:na] + at cc.bnblogs.springdatajpa.config.filter.JwtAuthenticationTokenFilter.doFilterInternal(JwtAuthenticationTokenFilter.java:40) ~[classes/:na] + ... 52 common frames omitted + +2023-04-13 14:25:24.729 ERROR 15424 --- [http-nio-8080-exec-5] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception + +java.lang.RuntimeException: io.jsonwebtoken.security.SignatureException: JWT signature does not match locally computed signature. JWT validity cannot be asserted and should not be trusted. + at cc.bnblogs.springdatajpa.config.filter.JwtAuthenticationTokenFilter.doFilterInternal(JwtAuthenticationTokenFilter.java:43) ~[classes/:na] + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:103) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:89) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:90) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:75) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:112) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:82) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:55) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.session.DisableEncodeUrlFilter.doFilterInternal(DisableEncodeUrlFilter.java:42) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:346) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:221) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:186) ~[spring-security-web-5.7.5.jar:5.7.5] + at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:354) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:267) ~[spring-web-5.3.24.jar:5.3.24] + at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.24.jar:5.3.24] + at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.24.jar:5.3.24] + at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.3.24.jar:5.3.24] + at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.24.jar:5.3.24] + at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:177) ~[tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:891) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1784) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) [tomcat-embed-core-9.0.69.jar:9.0.69] + at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.69.jar:9.0.69] + at java.lang.Thread.run(Thread.java:748) [na:1.8.0_201] +Caused by: io.jsonwebtoken.security.SignatureException: JWT signature does not match locally computed signature. JWT validity cannot be asserted and should not be trusted. + at io.jsonwebtoken.impl.DefaultJwtParser.parse(DefaultJwtParser.java:399) ~[jjwt-impl-0.11.5.jar:0.11.5] + at io.jsonwebtoken.impl.DefaultJwtParser.parse(DefaultJwtParser.java:529) ~[jjwt-impl-0.11.5.jar:0.11.5] + at io.jsonwebtoken.impl.DefaultJwtParser.parseClaimsJws(DefaultJwtParser.java:589) ~[jjwt-impl-0.11.5.jar:0.11.5] + at io.jsonwebtoken.impl.ImmutableJwtParser.parseClaimsJws(ImmutableJwtParser.java:173) ~[jjwt-impl-0.11.5.jar:0.11.5] + at cc.bnblogs.springdatajpa.utils.JwtUtil.parseJWT(JwtUtil.java:65) ~[classes/:na] + at cc.bnblogs.springdatajpa.config.filter.JwtAuthenticationTokenFilter.doFilterInternal(JwtAuthenticationTokenFilter.java:40) ~[classes/:na] + ... 52 common frames omitted + +2023-04-13 14:31:33.407 INFO 15424 --- [File Watcher] rtingClassPathChangeChangedEventListener : Restarting due to 18 class path changes (0 additions, 17 deletions, 1 modification) +2023-04-13 14:31:33.542 INFO 15424 --- [Thread-12] o.apache.catalina.core.StandardService : Stopping service [Tomcat] +2023-04-13 14:31:33.543 INFO 15424 --- [Thread-12] o.a.c.c.C.[Tomcat].[localhost].[/] : Destroying Spring FrameworkServlet 'dispatcherServlet' +2023-04-13 14:31:33.546 WARN 15424 --- [Thread-12] o.a.c.loader.WebappClassLoaderBase : The web application [ROOT] appears to have started a thread named [HikariPool-1 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:748) +2023-04-13 14:31:33.550 INFO 15424 --- [Thread-12] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default' +2023-04-13 14:31:33.552 INFO 15424 --- [Thread-12] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated... +2023-04-13 14:31:33.556 INFO 15424 --- [Thread-12] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed. +2023-04-13 14:31:33.770 INFO 15424 --- [restartedMain] c.b.s.SpringDataJpaApplication : Starting SpringDataJpaApplication using Java 1.8.0_201 on DESKTOP-AH1VP76 with PID 15424 (D:\spring_study\SpringDataJPA\target\classes started by zfp in D:\spring_study\SpringDataJPA) +2023-04-13 14:31:33.771 INFO 15424 --- [restartedMain] c.b.s.SpringDataJpaApplication : No active profile set, falling back to 1 default profile: "default" +2023-04-13 14:31:33.917 INFO 15424 --- [restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode. +2023-04-13 14:31:33.918 INFO 15424 --- [restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 0 ms. Found 0 JPA repository interfaces. +2023-04-13 14:31:34.092 INFO 15424 --- [restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) +2023-04-13 14:31:34.093 INFO 15424 --- [restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat] +2023-04-13 14:31:34.093 INFO 15424 --- [restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.69] +2023-04-13 14:31:34.122 INFO 15424 --- [restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext +2023-04-13 14:31:34.122 INFO 15424 --- [restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 349 ms +2023-04-13 14:31:34.176 INFO 15424 --- [restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default] +2023-04-13 14:31:34.182 INFO 15424 --- [restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-2 - Starting... +2023-04-13 14:31:34.203 INFO 15424 --- [restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-2 - Start completed. +2023-04-13 14:31:34.204 INFO 15424 --- [restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL8Dialect +2023-04-13 14:31:34.220 INFO 15424 --- [restartedMain] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform] +2023-04-13 14:31:34.220 INFO 15424 --- [restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default' +2023-04-13 14:31:34.236 WARN 15424 --- [restartedMain] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning +2023-04-13 14:31:34.336 WARN 15424 --- [restartedMain] .s.s.UserDetailsServiceAutoConfiguration : + +Using generated security password: 7bb84469-6940-41df-8555-5f9980418753 + +This generated password is for development use only. Your security configuration must be updated before running your application in production. + +2023-04-13 14:31:34.373 INFO 15424 --- [restartedMain] o.s.s.web.DefaultSecurityFilterChain : Will secure any request with [org.springframework.security.web.session.DisableEncodeUrlFilter@4802f67a, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@14bf63a, org.springframework.security.web.context.SecurityContextPersistenceFilter@1b6bb2c, org.springframework.security.web.header.HeaderWriterFilter@5068eee4, org.springframework.security.web.csrf.CsrfFilter@3df807d, org.springframework.security.web.authentication.logout.LogoutFilter@4524cb24, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@41f62529, org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter@7de41da6, org.springframework.security.web.authentication.ui.DefaultLogoutPageGeneratingFilter@649669fa, org.springframework.security.web.authentication.www.BasicAuthenticationFilter@5386c7de, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@1f55b221, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@8dd70e1, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@5db1be4b, org.springframework.security.web.session.SessionManagementFilter@2fcb40fc, org.springframework.security.web.access.ExceptionTranslationFilter@461b1cdf, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@38fa75f3] +2023-04-13 14:31:34.390 INFO 15424 --- [restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729 +2023-04-13 14:31:34.406 INFO 15424 --- [restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path '' +2023-04-13 14:31:34.411 INFO 15424 --- [restartedMain] c.b.s.SpringDataJpaApplication : Started SpringDataJpaApplication in 0.678 seconds (JVM running for 1173.404) +2023-04-13 14:31:34.417 INFO 15424 --- [restartedMain] .ConditionEvaluationDeltaLoggingListener : Condition evaluation delta: + + +========================== +CONDITION EVALUATION DELTA +========================== + + +Positive matches: +----------------- + + SpringBootWebSecurityConfiguration.SecurityFilterChainConfiguration matched: + - AllNestedConditions 2 matched 0 did not; NestedCondition on DefaultWebSecurityCondition.Beans @ConditionalOnMissingBean (types: org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter,org.springframework.security.web.SecurityFilterChain; SearchStrategy: all) did not find any beans; NestedCondition on DefaultWebSecurityCondition.Classes @ConditionalOnClass found required classes 'org.springframework.security.web.SecurityFilterChain', 'org.springframework.security.config.annotation.web.builders.HttpSecurity' (DefaultWebSecurityCondition) + + SpringBootWebSecurityConfiguration.WebSecurityEnablerConfiguration matched: + - @ConditionalOnClass found required class 'org.springframework.security.config.annotation.web.configuration.EnableWebSecurity' (OnClassCondition) + - @ConditionalOnMissingBean (names: springSecurityFilterChain; SearchStrategy: all) did not find any beans (OnBeanCondition) + + UserDetailsServiceAutoConfiguration matched: + - @ConditionalOnClass found required class 'org.springframework.security.authentication.AuthenticationManager' (OnClassCondition) + - @ConditionalOnBean (types: org.springframework.security.config.annotation.ObjectPostProcessor; SearchStrategy: all) found bean 'objectPostProcessor'; @ConditionalOnMissingBean (types: org.springframework.security.authentication.AuthenticationManager,org.springframework.security.authentication.AuthenticationProvider,org.springframework.security.core.userdetails.UserDetailsService,org.springframework.security.authentication.AuthenticationManagerResolver,org.springframework.security.oauth2.jwt.JwtDecoder,org.springframework.security.oauth2.server.resource.introspection.OpaqueTokenIntrospector,org.springframework.security.oauth2.client.registration.ClientRegistrationRepository,org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistrationRepository; SearchStrategy: all) did not find any beans (OnBeanCondition) + + +Negative matches: +----------------- + + None + + +Exclusions: +----------- + + None + + +Unconditional classes: +---------------------- + + None + + + +2023-04-13 14:31:37.814 INFO 15424 --- [File Watcher] rtingClassPathChangeChangedEventListener : Restarting due to 17 class path changes (17 additions, 0 deletions, 0 modifications) +2023-04-13 14:31:38.011 INFO 15424 --- [Thread-18] o.apache.catalina.core.StandardService : Stopping service [Tomcat] +2023-04-13 14:31:38.024 INFO 15424 --- [Thread-18] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default' +2023-04-13 14:31:38.025 INFO 15424 --- [Thread-18] com.zaxxer.hikari.HikariDataSource : HikariPool-2 - Shutdown initiated... +2023-04-13 14:31:38.036 INFO 15424 --- [Thread-18] com.zaxxer.hikari.HikariDataSource : HikariPool-2 - Shutdown completed. +2023-04-13 14:31:38.236 INFO 15424 --- [restartedMain] c.b.s.SpringDataJpaApplication : Starting SpringDataJpaApplication using Java 1.8.0_201 on DESKTOP-AH1VP76 with PID 15424 (D:\spring_study\SpringDataJPA\target\classes started by zfp in D:\spring_study\SpringDataJPA) +2023-04-13 14:31:38.237 INFO 15424 --- [restartedMain] c.b.s.SpringDataJpaApplication : No active profile set, falling back to 1 default profile: "default" +2023-04-13 14:31:38.402 INFO 15424 --- [restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode. +2023-04-13 14:31:38.414 INFO 15424 --- [restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 11 ms. Found 1 JPA repository interfaces. +2023-04-13 14:31:38.501 INFO 15424 --- [restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) +2023-04-13 14:31:38.502 INFO 15424 --- [restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat] +2023-04-13 14:31:38.502 INFO 15424 --- [restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.69] +2023-04-13 14:31:38.519 INFO 15424 --- [restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext +2023-04-13 14:31:38.519 INFO 15424 --- [restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 280 ms +2023-04-13 14:31:38.547 INFO 15424 --- [restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default] +2023-04-13 14:31:38.552 INFO 15424 --- [restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-3 - Starting... +2023-04-13 14:31:38.569 INFO 15424 --- [restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-3 - Start completed. +2023-04-13 14:31:38.569 INFO 15424 --- [restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL8Dialect +2023-04-13 14:31:38.595 INFO 15424 --- [restartedMain] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform] +2023-04-13 14:31:38.595 INFO 15424 --- [restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default' +2023-04-13 14:31:38.697 WARN 15424 --- [restartedMain] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning +2023-04-13 14:31:38.745 INFO 15424 --- [restartedMain] o.s.s.web.DefaultSecurityFilterChain : Will secure any request with [org.springframework.security.web.session.DisableEncodeUrlFilter@7e020755, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@541bd7dd, org.springframework.security.web.context.SecurityContextPersistenceFilter@34f45384, org.springframework.security.web.header.HeaderWriterFilter@2983e93a, org.springframework.security.web.authentication.logout.LogoutFilter@122e6826, cc.bnblogs.springdatajpa.config.filter.JwtAuthenticationTokenFilter@e30c63c, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@d58b64a, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@3b2444e2, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@259ebbb0, org.springframework.security.web.session.SessionManagementFilter@d965ba6, org.springframework.security.web.access.ExceptionTranslationFilter@1ba44626, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@70bf2e09] +2023-04-13 14:31:38.869 INFO 15424 --- [restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729 +2023-04-13 14:31:38.878 INFO 15424 --- [restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path '' +2023-04-13 14:31:38.883 INFO 15424 --- [restartedMain] c.b.s.SpringDataJpaApplication : Started SpringDataJpaApplication in 0.68 seconds (JVM running for 1177.878) +2023-04-13 14:31:38.885 INFO 15424 --- [restartedMain] .ConditionEvaluationDeltaLoggingListener : Condition evaluation delta: + + +========================== +CONDITION EVALUATION DELTA +========================== + + +Positive matches: +----------------- + + None + + +Negative matches: +----------------- + + SpringBootWebSecurityConfiguration.SecurityFilterChainConfiguration: + Did not match: + - AllNestedConditions 1 matched 1 did not; NestedCondition on DefaultWebSecurityCondition.Beans @ConditionalOnMissingBean (types: org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter,org.springframework.security.web.SecurityFilterChain; SearchStrategy: all) found beans of type 'org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter' securityConfig; NestedCondition on DefaultWebSecurityCondition.Classes @ConditionalOnClass found required classes 'org.springframework.security.web.SecurityFilterChain', 'org.springframework.security.config.annotation.web.builders.HttpSecurity' (DefaultWebSecurityCondition) + + SpringBootWebSecurityConfiguration.WebSecurityEnablerConfiguration: + Did not match: + - @ConditionalOnMissingBean (names: springSecurityFilterChain; SearchStrategy: all) found beans named springSecurityFilterChain (OnBeanCondition) + Matched: + - @ConditionalOnClass found required class 'org.springframework.security.config.annotation.web.configuration.EnableWebSecurity' (OnClassCondition) + + UserDetailsServiceAutoConfiguration: + Did not match: + - @ConditionalOnMissingBean (types: org.springframework.security.authentication.AuthenticationManager,org.springframework.security.authentication.AuthenticationProvider,org.springframework.security.core.userdetails.UserDetailsService,org.springframework.security.authentication.AuthenticationManagerResolver,org.springframework.security.oauth2.jwt.JwtDecoder,org.springframework.security.oauth2.server.resource.introspection.OpaqueTokenIntrospector,org.springframework.security.oauth2.client.registration.ClientRegistrationRepository,org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistrationRepository; SearchStrategy: all) found beans of type 'org.springframework.security.authentication.AuthenticationManager' authenticationManagerBean and found beans of type 'org.springframework.security.core.userdetails.UserDetailsService' userDetailServiceImpl (OnBeanCondition) + Matched: + - @ConditionalOnClass found required class 'org.springframework.security.authentication.AuthenticationManager' (OnClassCondition) + + +Exclusions: +----------- + + None + + +Unconditional classes: +---------------------- + + None + + + +2023-04-13 14:31:56.458 INFO 15424 --- [SpringApplicationShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default' +2023-04-13 14:31:56.458 INFO 15424 --- [SpringApplicationShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-3 - Shutdown initiated... +2023-04-13 14:31:56.465 INFO 15424 --- [SpringApplicationShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-3 - Shutdown completed. +2023-04-13 14:33:50.275 INFO 8324 --- [main] c.b.springdatajpa.mapper.UserMapperTest : Starting UserMapperTest using Java 1.8.0_201 on DESKTOP-AH1VP76 with PID 8324 (started by zfp in D:\spring_study\SpringDataJPA) +2023-04-13 14:33:50.276 INFO 8324 --- [main] c.b.springdatajpa.mapper.UserMapperTest : No active profile set, falling back to 1 default profile: "default" +2023-04-13 14:33:50.948 INFO 8324 --- [main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode. +2023-04-13 14:33:51.006 INFO 8324 --- [main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 48 ms. Found 1 JPA repository interfaces. +2023-04-13 14:33:51.681 INFO 8324 --- [main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default] +2023-04-13 14:33:51.744 INFO 8324 --- [main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.6.14.Final +2023-04-13 14:33:52.007 INFO 8324 --- [main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final} +2023-04-13 14:33:52.270 INFO 8324 --- [main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting... +2023-04-13 14:33:52.760 INFO 8324 --- [main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed. +2023-04-13 14:33:52.792 INFO 8324 --- [main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL8Dialect +2023-04-13 14:33:53.498 INFO 8324 --- [main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform] +2023-04-13 14:33:53.507 INFO 8324 --- [main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default' +2023-04-13 14:33:53.575 WARN 8324 --- [main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning +2023-04-13 14:33:54.741 INFO 8324 --- [main] o.s.s.web.DefaultSecurityFilterChain : Will secure any request with [org.springframework.security.web.session.DisableEncodeUrlFilter@7a730479, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@1e5b33e5, org.springframework.security.web.context.SecurityContextPersistenceFilter@4fedf908, org.springframework.security.web.header.HeaderWriterFilter@1be3f8f8, org.springframework.security.web.authentication.logout.LogoutFilter@6ebbc06, cc.bnblogs.springdatajpa.config.filter.JwtAuthenticationTokenFilter@120411ec, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@241d1052, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@4fd37449, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@654b899f, org.springframework.security.web.session.SessionManagementFilter@2a16d4dc, org.springframework.security.web.access.ExceptionTranslationFilter@2efcc0b3, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@1f68e4e8] +2023-04-13 14:33:55.542 INFO 8324 --- [main] c.b.springdatajpa.mapper.UserMapperTest : Started UserMapperTest in 5.627 seconds (JVM running for 6.906) +2023-04-13 14:33:55.698 INFO 8324 --- [SpringApplicationShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default' +2023-04-13 14:33:55.700 INFO 8324 --- [SpringApplicationShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated... +2023-04-13 14:33:55.707 INFO 8324 --- [SpringApplicationShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed. +2023-04-13 14:34:40.512 INFO 15156 --- [main] c.b.springdatajpa.mapper.UserMapperTest : Starting UserMapperTest using Java 1.8.0_201 on DESKTOP-AH1VP76 with PID 15156 (started by zfp in D:\spring_study\SpringDataJPA) +2023-04-13 14:34:40.514 INFO 15156 --- [main] c.b.springdatajpa.mapper.UserMapperTest : No active profile set, falling back to 1 default profile: "default" +2023-04-13 14:34:41.170 INFO 15156 --- [main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode. +2023-04-13 14:34:41.226 INFO 15156 --- [main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 45 ms. Found 1 JPA repository interfaces. +2023-04-13 14:34:41.757 INFO 15156 --- [main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default] +2023-04-13 14:34:41.809 INFO 15156 --- [main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.6.14.Final +2023-04-13 14:34:42.016 INFO 15156 --- [main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final} +2023-04-13 14:34:42.269 INFO 15156 --- [main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting... +2023-04-13 14:34:42.783 INFO 15156 --- [main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed. +2023-04-13 14:34:42.823 INFO 15156 --- [main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL8Dialect +2023-04-13 14:34:43.504 INFO 15156 --- [main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform] +2023-04-13 14:34:43.514 INFO 15156 --- [main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default' +2023-04-13 14:34:43.585 WARN 15156 --- [main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning +2023-04-13 14:34:44.715 INFO 15156 --- [main] o.s.s.web.DefaultSecurityFilterChain : Will secure any request with [org.springframework.security.web.session.DisableEncodeUrlFilter@1e5b33e5, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@654b899f, org.springframework.security.web.context.SecurityContextPersistenceFilter@5341641d, org.springframework.security.web.header.HeaderWriterFilter@78b9155e, org.springframework.security.web.authentication.logout.LogoutFilter@50672905, cc.bnblogs.springdatajpa.config.filter.JwtAuthenticationTokenFilter@6cc8adff, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@7b3c0ecb, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@5402612e, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@71468613, org.springframework.security.web.session.SessionManagementFilter@75805562, org.springframework.security.web.access.ExceptionTranslationFilter@4a453f8d, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@47b4ac83] +2023-04-13 14:34:45.569 INFO 15156 --- [main] c.b.springdatajpa.mapper.UserMapperTest : Started UserMapperTest in 5.423 seconds (JVM running for 6.64) +2023-04-13 14:34:45.755 INFO 15156 --- [SpringApplicationShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default' +2023-04-13 14:34:45.758 INFO 15156 --- [SpringApplicationShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated... +2023-04-13 14:34:45.761 INFO 15156 --- [SpringApplicationShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed. +2023-04-13 14:35:03.800 INFO 7568 --- [main] c.b.springdatajpa.mapper.UserMapperTest : Starting UserMapperTest using Java 1.8.0_201 on DESKTOP-AH1VP76 with PID 7568 (started by zfp in D:\spring_study\SpringDataJPA) +2023-04-13 14:35:03.800 INFO 7568 --- [main] c.b.springdatajpa.mapper.UserMapperTest : No active profile set, falling back to 1 default profile: "default" +2023-04-13 14:35:04.587 INFO 7568 --- [main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode. +2023-04-13 14:35:04.643 INFO 7568 --- [main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 47 ms. Found 1 JPA repository interfaces. +2023-04-13 14:35:05.184 INFO 7568 --- [main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default] +2023-04-13 14:35:05.234 INFO 7568 --- [main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.6.14.Final +2023-04-13 14:35:05.432 INFO 7568 --- [main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final} +2023-04-13 14:35:05.696 INFO 7568 --- [main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting... +2023-04-13 14:35:06.181 INFO 7568 --- [main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed. +2023-04-13 14:35:06.213 INFO 7568 --- [main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL8Dialect +2023-04-13 14:35:06.808 INFO 7568 --- [main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform] +2023-04-13 14:35:06.815 INFO 7568 --- [main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default' +2023-04-13 14:35:06.884 WARN 7568 --- [main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning +2023-04-13 14:35:08.135 INFO 7568 --- [main] o.s.s.web.DefaultSecurityFilterChain : Will secure any request with [org.springframework.security.web.session.DisableEncodeUrlFilter@5477d90e, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@6dc9a56e, org.springframework.security.web.context.SecurityContextPersistenceFilter@3006bfb, org.springframework.security.web.header.HeaderWriterFilter@59e0d521, org.springframework.security.web.authentication.logout.LogoutFilter@6ae42248, cc.bnblogs.springdatajpa.config.filter.JwtAuthenticationTokenFilter@333a44f2, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@5402612e, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@5072e638, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@287ad0da, org.springframework.security.web.session.SessionManagementFilter@241d1052, org.springframework.security.web.access.ExceptionTranslationFilter@78b9155e, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@3f45dfec] +2023-04-13 14:35:09.162 INFO 7568 --- [main] c.b.springdatajpa.mapper.UserMapperTest : Started UserMapperTest in 5.752 seconds (JVM running for 7.009) +2023-04-13 14:35:09.384 INFO 7568 --- [SpringApplicationShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default' +2023-04-13 14:35:09.386 INFO 7568 --- [SpringApplicationShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated... +2023-04-13 14:35:09.392 INFO 7568 --- [SpringApplicationShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed. +2023-04-13 14:35:22.222 INFO 10176 --- [main] c.b.springdatajpa.mapper.UserMapperTest : Starting UserMapperTest using Java 1.8.0_201 on DESKTOP-AH1VP76 with PID 10176 (started by zfp in D:\spring_study\SpringDataJPA) +2023-04-13 14:35:22.223 INFO 10176 --- [main] c.b.springdatajpa.mapper.UserMapperTest : No active profile set, falling back to 1 default profile: "default" +2023-04-13 14:35:23.303 INFO 10176 --- [main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode. +2023-04-13 14:35:23.395 INFO 10176 --- [main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 74 ms. Found 1 JPA repository interfaces. +2023-04-13 14:35:24.127 INFO 10176 --- [main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default] +2023-04-13 14:35:24.178 INFO 10176 --- [main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.6.14.Final +2023-04-13 14:35:24.388 INFO 10176 --- [main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final} +2023-04-13 14:35:24.730 INFO 10176 --- [main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting... +2023-04-13 14:35:25.220 INFO 10176 --- [main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed. +2023-04-13 14:35:25.264 INFO 10176 --- [main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL8Dialect +2023-04-13 14:35:25.981 INFO 10176 --- [main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform] +2023-04-13 14:35:25.991 INFO 10176 --- [main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default' +2023-04-13 14:35:26.063 WARN 10176 --- [main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning +2023-04-13 14:35:27.099 INFO 10176 --- [main] o.s.s.web.DefaultSecurityFilterChain : Will secure any request with [org.springframework.security.web.session.DisableEncodeUrlFilter@13f4048e, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@5477d90e, org.springframework.security.web.context.SecurityContextPersistenceFilter@5bb99d1d, org.springframework.security.web.header.HeaderWriterFilter@69c33ea2, org.springframework.security.web.authentication.logout.LogoutFilter@3220c28, cc.bnblogs.springdatajpa.config.filter.JwtAuthenticationTokenFilter@1a34a51e, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@4fd37449, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@17befef0, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@6dc9a56e, org.springframework.security.web.session.SessionManagementFilter@5341641d, org.springframework.security.web.access.ExceptionTranslationFilter@1be3f8f8, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@5df7a065] +2023-04-13 14:35:28.209 INFO 10176 --- [main] c.b.springdatajpa.mapper.UserMapperTest : Started UserMapperTest in 6.389 seconds (JVM running for 7.595) +2023-04-13 14:35:28.502 INFO 10176 --- [SpringApplicationShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default' +2023-04-13 14:35:28.504 INFO 10176 --- [SpringApplicationShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated... +2023-04-13 14:35:28.514 INFO 10176 --- [SpringApplicationShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed. +2023-04-13 14:35:58.290 INFO 7648 --- [main] c.b.springdatajpa.mapper.UserMapperTest : Starting UserMapperTest using Java 1.8.0_201 on DESKTOP-AH1VP76 with PID 7648 (started by zfp in D:\spring_study\SpringDataJPA) +2023-04-13 14:35:58.291 INFO 7648 --- [main] c.b.springdatajpa.mapper.UserMapperTest : No active profile set, falling back to 1 default profile: "default" +2023-04-13 14:35:58.949 INFO 7648 --- [main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode. +2023-04-13 14:35:59.033 INFO 7648 --- [main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 67 ms. Found 1 JPA repository interfaces. +2023-04-13 14:35:59.625 INFO 7648 --- [main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default] +2023-04-13 14:35:59.685 INFO 7648 --- [main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.6.14.Final +2023-04-13 14:35:59.901 INFO 7648 --- [main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final} +2023-04-13 14:36:00.162 INFO 7648 --- [main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting... +2023-04-13 14:36:00.635 INFO 7648 --- [main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed. +2023-04-13 14:36:00.676 INFO 7648 --- [main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL8Dialect +2023-04-13 14:36:01.262 INFO 7648 --- [main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform] +2023-04-13 14:36:01.271 INFO 7648 --- [main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default' +2023-04-13 14:36:01.336 WARN 7648 --- [main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning +2023-04-13 14:36:02.301 INFO 7648 --- [main] o.s.s.web.DefaultSecurityFilterChain : Will secure any request with [org.springframework.security.web.session.DisableEncodeUrlFilter@13f4048e, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@5477d90e, org.springframework.security.web.context.SecurityContextPersistenceFilter@5bb99d1d, org.springframework.security.web.header.HeaderWriterFilter@69c33ea2, org.springframework.security.web.authentication.logout.LogoutFilter@3220c28, cc.bnblogs.springdatajpa.config.filter.JwtAuthenticationTokenFilter@1a34a51e, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@4fd37449, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@17befef0, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@6dc9a56e, org.springframework.security.web.session.SessionManagementFilter@5341641d, org.springframework.security.web.access.ExceptionTranslationFilter@1be3f8f8, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@5df7a065] +2023-04-13 14:36:03.302 INFO 7648 --- [main] c.b.springdatajpa.mapper.UserMapperTest : Started UserMapperTest in 5.51 seconds (JVM running for 6.716) +2023-04-13 14:36:03.515 INFO 7648 --- [SpringApplicationShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default' +2023-04-13 14:36:03.517 INFO 7648 --- [SpringApplicationShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated... +2023-04-13 14:36:03.525 INFO 7648 --- [SpringApplicationShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed. +2023-04-13 14:36:09.009 INFO 14764 --- [main] c.b.springdatajpa.mapper.UserMapperTest : Starting UserMapperTest using Java 1.8.0_201 on DESKTOP-AH1VP76 with PID 14764 (started by zfp in D:\spring_study\SpringDataJPA) +2023-04-13 14:36:09.013 INFO 14764 --- [main] c.b.springdatajpa.mapper.UserMapperTest : No active profile set, falling back to 1 default profile: "default" +2023-04-13 14:36:09.716 INFO 14764 --- [main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode. +2023-04-13 14:36:09.772 INFO 14764 --- [main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 48 ms. Found 1 JPA repository interfaces. +2023-04-13 14:36:10.355 INFO 14764 --- [main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default] +2023-04-13 14:36:10.415 INFO 14764 --- [main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.6.14.Final +2023-04-13 14:36:10.624 INFO 14764 --- [main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final} +2023-04-13 14:36:10.890 INFO 14764 --- [main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting... +2023-04-13 14:36:11.358 INFO 14764 --- [main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed. +2023-04-13 14:36:11.391 INFO 14764 --- [main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL8Dialect +2023-04-13 14:36:11.986 INFO 14764 --- [main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform] +2023-04-13 14:36:11.993 INFO 14764 --- [main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default' +2023-04-13 14:36:12.066 WARN 14764 --- [main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning +2023-04-13 14:36:13.246 INFO 14764 --- [main] o.s.s.web.DefaultSecurityFilterChain : Will secure any request with [org.springframework.security.web.session.DisableEncodeUrlFilter@1e5b33e5, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@654b899f, org.springframework.security.web.context.SecurityContextPersistenceFilter@5341641d, org.springframework.security.web.header.HeaderWriterFilter@78b9155e, org.springframework.security.web.authentication.logout.LogoutFilter@50672905, cc.bnblogs.springdatajpa.config.filter.JwtAuthenticationTokenFilter@6cc8adff, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@7b3c0ecb, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@5402612e, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@71468613, org.springframework.security.web.session.SessionManagementFilter@75805562, org.springframework.security.web.access.ExceptionTranslationFilter@4a453f8d, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@47b4ac83] +2023-04-13 14:36:14.262 INFO 14764 --- [main] c.b.springdatajpa.mapper.UserMapperTest : Started UserMapperTest in 5.674 seconds (JVM running for 6.966) +2023-04-13 14:36:14.481 INFO 14764 --- [SpringApplicationShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default' +2023-04-13 14:36:14.484 INFO 14764 --- [SpringApplicationShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated... +2023-04-13 14:36:14.492 INFO 14764 --- [SpringApplicationShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed. diff --git a/SpringDataJPA/src/test/java/cc/bnblogs/springdatajpa/mapper/UserMapperTest.java b/SpringDataJPA/src/test/java/cc/bnblogs/springdatajpa/mapper/UserMapperTest.java index c02107e..7f38b9b 100644 --- a/SpringDataJPA/src/test/java/cc/bnblogs/springdatajpa/mapper/UserMapperTest.java +++ b/SpringDataJPA/src/test/java/cc/bnblogs/springdatajpa/mapper/UserMapperTest.java @@ -32,15 +32,15 @@ class UserMapperTest { @Test void getDataByID(){ - Optional user = userMapper.findById(10); + Optional user = userMapper.findById(16); user.ifPresent(System.out::println); } @Test void updateDataByID(){ - Optional user = userMapper.findById(10); + Optional user = userMapper.findById(16); user.ifPresent(u -> { - u.setName("张三"); + u.setName("admin"); User user0 = userMapper.save(u); System.out.println(user0); }); @@ -48,8 +48,8 @@ class UserMapperTest { @Test void deleteByID() { - userMapper.deleteById(10); - System.out.println(userMapper.findById(10).isPresent()); + userMapper.deleteById(16); + System.out.println(userMapper.findById(16).isPresent()); } @Test diff --git a/SpringSecurity/.gitignore b/SpringSecurity/.gitignore new file mode 100644 index 0000000..549e00a --- /dev/null +++ b/SpringSecurity/.gitignore @@ -0,0 +1,33 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ diff --git a/SpringSecurity/.mvn/wrapper/maven-wrapper.jar b/SpringSecurity/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 0000000..bf82ff0 Binary files /dev/null and b/SpringSecurity/.mvn/wrapper/maven-wrapper.jar differ diff --git a/SpringSecurity/.mvn/wrapper/maven-wrapper.properties b/SpringSecurity/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..ca5ab4b --- /dev/null +++ b/SpringSecurity/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar diff --git a/SpringSecurity/mvnw b/SpringSecurity/mvnw new file mode 100644 index 0000000..8a8fb22 --- /dev/null +++ b/SpringSecurity/mvnw @@ -0,0 +1,316 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /usr/local/etc/mavenrc ] ; then + . /usr/local/etc/mavenrc + fi + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`\\unset -f command; \\command -v java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + fi + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=`cygpath --path --windows "$javaClass"` + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + $MAVEN_DEBUG_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" \ + "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/SpringSecurity/mvnw.cmd b/SpringSecurity/mvnw.cmd new file mode 100644 index 0000000..1d8ab01 --- /dev/null +++ b/SpringSecurity/mvnw.cmd @@ -0,0 +1,188 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* +if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + +FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% ^ + %JVM_CONFIG_MAVEN_PROPS% ^ + %MAVEN_OPTS% ^ + %MAVEN_DEBUG_OPTS% ^ + -classpath %WRAPPER_JAR% ^ + "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ + %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" +if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%"=="on" pause + +if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% + +cmd /C exit /B %ERROR_CODE% diff --git a/SpringSecurity/pom.xml b/SpringSecurity/pom.xml new file mode 100644 index 0000000..a3256f0 --- /dev/null +++ b/SpringSecurity/pom.xml @@ -0,0 +1,103 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.7.10 + + + cc.bnblogs + SpringSecurity + 0.0.1-SNAPSHOT + SpringSecurity + SpringSecurity + + 1.8 + + + + org.springframework.boot + spring-boot-starter-security + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-devtools + runtime + true + + + + org.projectlombok + lombok + true + + + + org.springframework.boot + spring-boot-starter-test + test + + + + org.springframework.security + spring-security-test + test + + + + org.springframework.social + spring-social-config + 1.1.6.RELEASE + + + + org.apache.commons + commons-lang3 + 3.12.0 + + + + com.mysql + mysql-connector-j + 8.0.32 + + + + + + + + + + org.springframework.boot + spring-boot-starter-jdbc + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + org.projectlombok + lombok + + + + + + + + diff --git a/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/Exception/ValidateCodeException.java b/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/Exception/ValidateCodeException.java new file mode 100644 index 0000000..0d1b28d --- /dev/null +++ b/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/Exception/ValidateCodeException.java @@ -0,0 +1,11 @@ +package cc.bnblogs.springsecurity.Exception; + +import org.springframework.security.core.AuthenticationException; + +public class ValidateCodeException extends AuthenticationException { + private static final long serialVersionUID = -2205230712358933815L; + + public ValidateCodeException(String message) { + super(message); + } +} \ No newline at end of file diff --git a/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/Service/UserDetailService.java b/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/Service/UserDetailService.java new file mode 100644 index 0000000..3ecd2ca --- /dev/null +++ b/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/Service/UserDetailService.java @@ -0,0 +1,31 @@ +package cc.bnblogs.springsecurity.Service; + +import cc.bnblogs.springsecurity.pojo.MyUser; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.core.authority.AuthorityUtils; +import org.springframework.security.core.userdetails.User; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.security.core.userdetails.UsernameNotFoundException; +import org.springframework.security.crypto.password.PasswordEncoder; + +@Configuration +public class UserDetailService implements UserDetailsService { + @Autowired + private PasswordEncoder passwordEncoder; + @Override + public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { + // 模拟一个用户,不使用数据库 + MyUser user = new MyUser(); + user.setUserName(username); + user.setPassword(this.passwordEncoder.encode("123456")); + // 输出加密后的密码 + System.out.println(user.getPassword()); + + + return new User(username, user.getPassword(), user.isEnabled(), + user.isAccountNonExpired(), user.isCredentialsNonExpired(), + user.isAccountNonLocked(), AuthorityUtils.commaSeparatedStringToAuthorityList("admin")); + } +} \ No newline at end of file diff --git a/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/SpringSecurityApplication.java b/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/SpringSecurityApplication.java new file mode 100644 index 0000000..e4e0a7c --- /dev/null +++ b/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/SpringSecurityApplication.java @@ -0,0 +1,13 @@ +package cc.bnblogs.springsecurity; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SpringSecurityApplication { + + public static void main(String[] args) { + SpringApplication.run(SpringSecurityApplication.class, args); + } + +} diff --git a/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/config/BrowserSecurityConfig.java b/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/config/BrowserSecurityConfig.java new file mode 100644 index 0000000..89c284e --- /dev/null +++ b/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/config/BrowserSecurityConfig.java @@ -0,0 +1,92 @@ +package cc.bnblogs.springsecurity.config; + +import cc.bnblogs.springsecurity.Service.UserDetailService; +import cc.bnblogs.springsecurity.validate.imagecode.ValidateCodeFilter; +import cc.bnblogs.springsecurity.validate.smscode.SmsAuthenticationConfig; +import cc.bnblogs.springsecurity.validate.smscode.SmsCodeFilter; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Lazy; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.security.crypto.password.PasswordEncoder; +import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; +import org.springframework.security.web.authentication.rememberme.JdbcTokenRepositoryImpl; +import org.springframework.security.web.authentication.rememberme.PersistentTokenRepository; + +import javax.sql.DataSource; + +@Configuration +public class BrowserSecurityConfig extends WebSecurityConfigurerAdapter { + + @Autowired + private MyAuthenticationSuccessHandler myAuthenticationSuccessHandler; + + @Autowired + private MyAuthenticationFailureHandler myAuthenticationFailureHandler; + + @Autowired + private ValidateCodeFilter validateCodeFilter; + + @Autowired + @Lazy + // 有循环引用问题 + private UserDetailService userDetailService; + + @Autowired + private DataSource dataSource; + + @Autowired + private SmsCodeFilter smsCodeFilter; + + @Autowired + @Lazy + private SmsAuthenticationConfig smsAuthenticationConfig; + + @Bean + public PersistentTokenRepository persistentTokenRepository() { + JdbcTokenRepositoryImpl jdbcTokenRepository = new JdbcTokenRepositoryImpl(); + jdbcTokenRepository.setDataSource(dataSource); + jdbcTokenRepository.setCreateTableOnStartup(false); + return jdbcTokenRepository; + } + + @Override + protected void configure(HttpSecurity http) throws Exception { + // 在检验用户名和密码前先校验验证码 + http.addFilterBefore(smsCodeFilter, UsernamePasswordAuthenticationFilter.class) + .formLogin()// 表单登录 + .loginPage("/authentication/require") + .loginProcessingUrl("/login/mobile") + .successHandler(myAuthenticationSuccessHandler) // 处理登录成功 + .failureHandler(myAuthenticationFailureHandler) // 处理登录失败 + .and() + .rememberMe() + .tokenRepository(persistentTokenRepository()) // 配置token持久化仓库 + .tokenValiditySeconds(3600) // remember 过期时间,单位为秒 + .userDetailsService(userDetailService) // 处理自动登录逻辑 + .and() + .authorizeRequests() // 授权配置 + .antMatchers("/authentication/require", + "/login.html", + "/css/*", + "/code/sms", + "/code/image").permitAll() + .anyRequest() // 所有请求 + .authenticated() // 都需要认证 + .and() + .csrf().disable(); // csrf + } + + /** + * 明文密码加密 + * + * @return + */ + @Bean + public PasswordEncoder passwordEncoder() { + return new BCryptPasswordEncoder(); + } +} diff --git a/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/config/MyAuthenticationFailureHandler.java b/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/config/MyAuthenticationFailureHandler.java new file mode 100644 index 0000000..861322f --- /dev/null +++ b/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/config/MyAuthenticationFailureHandler.java @@ -0,0 +1,27 @@ +package cc.bnblogs.springsecurity.config; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.web.authentication.AuthenticationFailureHandler; +import org.springframework.stereotype.Component; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +@Component +public class MyAuthenticationFailureHandler implements AuthenticationFailureHandler { + + @Autowired + private ObjectMapper mapper; + + @Override + public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, + AuthenticationException exception) throws IOException { + response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value()); + response.setContentType("application/json;charset=utf-8"); + response.getWriter().write(mapper.writeValueAsString(exception.getMessage())); + } +} \ No newline at end of file diff --git a/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/config/MyAuthenticationSuccessHandler.java b/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/config/MyAuthenticationSuccessHandler.java new file mode 100644 index 0000000..9b516e4 --- /dev/null +++ b/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/config/MyAuthenticationSuccessHandler.java @@ -0,0 +1,35 @@ +package cc.bnblogs.springsecurity.config; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.springframework.security.core.Authentication; +import org.springframework.security.web.DefaultRedirectStrategy; +import org.springframework.security.web.RedirectStrategy; +import org.springframework.security.web.authentication.AuthenticationSuccessHandler; +import org.springframework.security.web.savedrequest.HttpSessionRequestCache; +import org.springframework.security.web.savedrequest.RequestCache; +import org.springframework.security.web.savedrequest.SavedRequest; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +@Component +public class MyAuthenticationSuccessHandler implements AuthenticationSuccessHandler { +// private RequestCache requestCache = new HttpSessionRequestCache(); + private RedirectStrategy redirectStrategy = new DefaultRedirectStrategy(); +// @Resource +// private ObjectMapper mapper; + @Override + public void onAuthenticationSuccess(HttpServletRequest request, + HttpServletResponse response, + Authentication authentication) + throws IOException{ +// response.setContentType("application/json;charset=utf-8"); +// response.getWriter().write(mapper.writeValueAsString(authentication)); +// SavedRequest savedRequest = requestCache.getRequest(request,response); +// redirectStrategy.sendRedirect(request,response, savedRequest.getRedirectUrl()); + redirectStrategy.sendRedirect(request, response, "/index"); + } +} diff --git a/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/controller/BrowserSecurityController.java b/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/controller/BrowserSecurityController.java new file mode 100644 index 0000000..8d7b426 --- /dev/null +++ b/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/controller/BrowserSecurityController.java @@ -0,0 +1,38 @@ +package cc.bnblogs.springsecurity.controller; + +import org.springframework.http.HttpStatus; +import org.springframework.security.web.DefaultRedirectStrategy; +import org.springframework.security.web.RedirectStrategy; +import org.springframework.security.web.savedrequest.HttpSessionRequestCache; +import org.springframework.security.web.savedrequest.RequestCache; +import org.springframework.security.web.savedrequest.SavedRequest; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +@RestController +public class BrowserSecurityController { + private final RequestCache requestCache = new HttpSessionRequestCache(); + private final RedirectStrategy redirectStrategy = new DefaultRedirectStrategy(); + + @GetMapping("/authentication/require") + @ResponseStatus(HttpStatus.UNAUTHORIZED) + public String requireAuthentication(HttpServletRequest request, HttpServletResponse response) throws IOException { + SavedRequest savedRequest = requestCache.getRequest(request,response); + if (savedRequest != null) { + String targetUrl = savedRequest.getRedirectUrl(); + if (StringUtils.endsWithIgnoreCase(targetUrl,".html")) { + redirectStrategy.sendRedirect(request,response,"/login.html"); + } + if (StringUtils.pathEquals(targetUrl,"http://localhost:8080/login")) { + redirectStrategy.sendRedirect(request,response,"/login.html"); + } + } + return "您访问的资源需要身份认证!"; + } +} diff --git a/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/controller/IndexController.java b/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/controller/IndexController.java new file mode 100644 index 0000000..2573299 --- /dev/null +++ b/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/controller/IndexController.java @@ -0,0 +1,23 @@ +package cc.bnblogs.springsecurity.controller; + +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class IndexController { + + @GetMapping("hello") + public String greet() { + System.out.println("hello"); + return "hello"; + } + + @GetMapping("index") + public Object index(Authentication authentication){ +// return SecurityContextHolder.getContext().getAuthentication(); + return authentication; + } + +} diff --git a/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/controller/ValidateCodeController.java b/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/controller/ValidateCodeController.java new file mode 100644 index 0000000..af384cd --- /dev/null +++ b/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/controller/ValidateCodeController.java @@ -0,0 +1,48 @@ +package cc.bnblogs.springsecurity.controller; + +import cc.bnblogs.springsecurity.pojo.SmsCode; +import cc.bnblogs.springsecurity.utils.ImageCodeUtils; +import cc.bnblogs.springsecurity.validate.imagecode.ImageCode; +import org.apache.commons.lang3.RandomStringUtils; +import org.springframework.social.connect.web.HttpSessionSessionStrategy; +import org.springframework.social.connect.web.SessionStrategy; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.context.request.ServletWebRequest; + +import javax.imageio.ImageIO; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +@RestController +public class ValidateCodeController { + + public final static String SESSION_KEY_IMAGE_CODE = "SESSION_KEY_IMAGE_CODE"; + public final static String SESSION_KEY_SMS_CODE = "SESSION_KEY_SMS_CODE"; + + + private final SessionStrategy sessionStrategy = new HttpSessionSessionStrategy(); + + @GetMapping("/code/image") + public void createCode(HttpServletRequest request, HttpServletResponse response) throws IOException { + ImageCode imageCode = ImageCodeUtils.createImageCode(); + // 将ImageCode对象保存到Session中 + sessionStrategy.setAttribute(new ServletWebRequest(request), SESSION_KEY_IMAGE_CODE, imageCode); + // 通过IO流将生成的图片输出到登录页面上 + ImageIO.write(imageCode.getImage(), "jpeg", response.getOutputStream()); + } + + @GetMapping("/code/sms") + public void createSmsCode(HttpServletRequest request, String mobile) { + SmsCode smsCode = createSMSCode(); + sessionStrategy.setAttribute(new ServletWebRequest(request), SESSION_KEY_SMS_CODE + mobile, smsCode); + // 输出验证码到控制台代替短信发送服务 + System.out.println("您的登录验证码为:" + smsCode.getCode() + ",有效时间为60秒"); + } + + private SmsCode createSMSCode() { + String code = RandomStringUtils.randomNumeric(6); + return new SmsCode(code, 60); + } +} \ No newline at end of file diff --git a/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/pojo/MyUser.java b/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/pojo/MyUser.java new file mode 100644 index 0000000..1c85ecc --- /dev/null +++ b/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/pojo/MyUser.java @@ -0,0 +1,23 @@ +package cc.bnblogs.springsecurity.pojo; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class MyUser implements Serializable { + + private static final long serialVersionUID = 7225349028293972637L; + + private String userName; + + private String password; + // 用户未过期 + private boolean accountNonExpired = true; + // 用户未锁定 + private boolean accountNonLocked= true; + // 权限认证未过期 + private boolean credentialsNonExpired= true; + // 用户可用 + private boolean enabled= true; +} \ No newline at end of file diff --git a/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/pojo/SmsCode.java b/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/pojo/SmsCode.java new file mode 100644 index 0000000..4c97f6c --- /dev/null +++ b/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/pojo/SmsCode.java @@ -0,0 +1,28 @@ +package cc.bnblogs.springsecurity.pojo; + +import lombok.Data; + +import java.time.LocalDateTime; + +/** + * 生成短信验证码 + */ +@Data +public class SmsCode { + private String code; // 短信验证码 + private LocalDateTime expireTime; // 过期时间 + + public SmsCode(String code, int expireIn) { + this.code = code; + this.expireTime = LocalDateTime.now().plusSeconds(expireIn); + } + + public SmsCode(String code, LocalDateTime expireTime) { + this.code = code; + this.expireTime = expireTime; + } + + boolean isExpire() { + return LocalDateTime.now().isAfter(expireTime); + } +} \ No newline at end of file diff --git a/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/utils/ImageCodeUtils.java b/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/utils/ImageCodeUtils.java new file mode 100644 index 0000000..13d4737 --- /dev/null +++ b/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/utils/ImageCodeUtils.java @@ -0,0 +1,62 @@ +package cc.bnblogs.springsecurity.utils; + + +import cc.bnblogs.springsecurity.validate.imagecode.ImageCode; + +import java.awt.*; +import java.awt.image.BufferedImage; +import java.util.Random; + +/** + * 生成图形验证码 + */ +public class ImageCodeUtils { + public static ImageCode createImageCode() { + + int width = 270; // 验证码图片宽度 + int height = 36; // 验证码图片长度 + int length = 4; // 验证码位数 + int expireIn = 60; // 验证码有效时间 60s + + BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); + Graphics g = image.getGraphics(); + + Random random = new Random(); + + g.setColor(getRandColor(200, 250)); + g.fillRect(0, 0, width, height); + g.setFont(new Font("Times New Roman", Font.ITALIC, 20)); + g.setColor(getRandColor(160, 200)); + for (int i = 0; i < 155; i++) { + int x = random.nextInt(width); + int y = random.nextInt(height); + int xl = random.nextInt(12); + int yl = random.nextInt(12); + g.drawLine(x, y, x + xl, y + yl); + } + + StringBuilder sRand = new StringBuilder(); + for (int i = 0; i < length; i++) { + String rand = String.valueOf(random.nextInt(10)); + sRand.append(rand); + g.setColor(new Color(20 + random.nextInt(110), 20 + random.nextInt(110), 20 + random.nextInt(110))); + g.drawString(rand, 100 + 13 * i + 6, 24); + } + g.dispose(); + return new ImageCode(image, sRand.toString(), expireIn); + } + + private static Color getRandColor(int fc, int bc) { + Random random = new Random(); + if (fc > 255) { + fc = 255; + } + if (bc > 255) { + bc = 255; + } + int r = fc + random.nextInt(bc - fc); + int g = fc + random.nextInt(bc - fc); + int b = fc + random.nextInt(bc - fc); + return new Color(r, g, b); + } +} diff --git a/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/validate/imagecode/ImageCode.java b/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/validate/imagecode/ImageCode.java new file mode 100644 index 0000000..f5a1d41 --- /dev/null +++ b/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/validate/imagecode/ImageCode.java @@ -0,0 +1,49 @@ +package cc.bnblogs.springsecurity.validate.imagecode; + +import lombok.Data; + +import java.awt.image.BufferedImage; +import java.time.LocalDateTime; + +@Data +public class ImageCode { + + private BufferedImage image; // 图片 + + private String code; // 验证码 + + private LocalDateTime expireTime; // 过期时间 + + /** + * 生成指定过期时间秒数的验证码 + * @param image + * @param code + * @param expireIn + */ + public ImageCode(BufferedImage image, String code, int expireIn) { + this.image = image; + this.code = code; + this.expireTime = LocalDateTime.now().plusSeconds(expireIn); + } + + /** + * 过期时间为LocalDateTime类型 + * @param image + * @param code + * @param expireTime + */ + + public ImageCode(BufferedImage image, String code, LocalDateTime expireTime) { + this.image = image; + this.code = code; + this.expireTime = expireTime; + } + + /** + * 验证码是否过期 + * @return + */ + public boolean isExpire() { + return LocalDateTime.now().isAfter(expireTime); + } +} \ No newline at end of file diff --git a/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/validate/imagecode/ValidateCodeFilter.java b/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/validate/imagecode/ValidateCodeFilter.java new file mode 100644 index 0000000..c18a28c --- /dev/null +++ b/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/validate/imagecode/ValidateCodeFilter.java @@ -0,0 +1,80 @@ +package cc.bnblogs.springsecurity.validate.imagecode; + +import cc.bnblogs.springsecurity.Exception.ValidateCodeException; +import cc.bnblogs.springsecurity.controller.ValidateCodeController; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.web.authentication.AuthenticationFailureHandler; +import org.springframework.social.connect.web.HttpSessionSessionStrategy; +import org.springframework.social.connect.web.SessionStrategy; +import org.springframework.stereotype.Component; +import org.springframework.web.bind.ServletRequestBindingException; +import org.springframework.web.bind.ServletRequestUtils; +import org.springframework.web.context.request.ServletWebRequest; +import org.springframework.web.filter.OncePerRequestFilter; + +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +/** + * 本过滤器只会校验一次 + */ +@Component +public class ValidateCodeFilter extends OncePerRequestFilter { + + @Autowired + private AuthenticationFailureHandler authenticationFailureHandler; + + private SessionStrategy sessionStrategy = new HttpSessionSessionStrategy(); + + @Override + protected void doFilterInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, + FilterChain filterChain) throws ServletException, IOException { + // 判断请求的路径和方法决定是否进行验证码校验 + if (StringUtils.equalsIgnoreCase("/login", httpServletRequest.getRequestURI()) + && StringUtils.equalsIgnoreCase(httpServletRequest.getMethod(), "post")) { + try { + validateCode(new ServletWebRequest(httpServletRequest)); + } catch (ValidateCodeException e) { + // 校验失败,返回对应错误信息 + authenticationFailureHandler.onAuthenticationFailure(httpServletRequest, httpServletResponse, e); + return; + } + } + // 不需要进行验证码校验,进入下一步 + filterChain.doFilter(httpServletRequest, httpServletResponse); + } + + /** + * 验证码校验 + * @param servletWebRequest + * @throws ServletRequestBindingException + */ + private void validateCode(ServletWebRequest servletWebRequest) throws ServletRequestBindingException { + // 从Session中取出ImageCode对象 + ImageCode codeInSession = (ImageCode) sessionStrategy.getAttribute(servletWebRequest, + ValidateCodeController.SESSION_KEY_IMAGE_CODE); + // 获取用户输入的验证码 + String codeInRequest = ServletRequestUtils.getStringParameter(servletWebRequest. + getRequest(), "imageCode"); + + if (StringUtils.isBlank(codeInRequest)) { + throw new ValidateCodeException("验证码不能为空!"); + } + if (codeInSession == null) { + throw new ValidateCodeException("验证码不存在!"); + } + if (codeInSession.isExpire()) { + sessionStrategy.removeAttribute(servletWebRequest, ValidateCodeController.SESSION_KEY_IMAGE_CODE); + throw new ValidateCodeException("验证码已过期!"); + } + if (!StringUtils.equalsIgnoreCase(codeInSession.getCode(), codeInRequest)) { + throw new ValidateCodeException("验证码不正确!"); + } + // 从Session中移除验证码对象 + sessionStrategy.removeAttribute(servletWebRequest, ValidateCodeController.SESSION_KEY_IMAGE_CODE); + } +} \ No newline at end of file diff --git a/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/validate/smscode/SmsAuthenticationConfig.java b/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/validate/smscode/SmsAuthenticationConfig.java new file mode 100644 index 0000000..80829ac --- /dev/null +++ b/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/validate/smscode/SmsAuthenticationConfig.java @@ -0,0 +1,40 @@ +package cc.bnblogs.springsecurity.validate.smscode; + +import cc.bnblogs.springsecurity.Service.UserDetailService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.config.annotation.SecurityConfigurerAdapter; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.web.DefaultSecurityFilterChain; +import org.springframework.security.web.authentication.AuthenticationFailureHandler; +import org.springframework.security.web.authentication.AuthenticationSuccessHandler; +import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; +import org.springframework.stereotype.Component; + +@Component +public class SmsAuthenticationConfig extends SecurityConfigurerAdapter { + + @Autowired + private AuthenticationSuccessHandler authenticationSuccessHandler; + + @Autowired + private AuthenticationFailureHandler authenticationFailureHandler; + + @Autowired + private UserDetailService userDetailService; + + @Override + public void configure(HttpSecurity http){ + SmsAuthenticationFilter smsAuthenticationFilter = new SmsAuthenticationFilter(); + smsAuthenticationFilter.setAuthenticationManager(http.getSharedObject(AuthenticationManager.class)); + smsAuthenticationFilter.setAuthenticationSuccessHandler(authenticationSuccessHandler); + smsAuthenticationFilter.setAuthenticationFailureHandler(authenticationFailureHandler); + + SmsAuthenticationProvider smsAuthenticationProvider = new SmsAuthenticationProvider(); + smsAuthenticationProvider.setUserDetailService(userDetailService); + + http.authenticationProvider(smsAuthenticationProvider) + .addFilterAfter(smsAuthenticationFilter, UsernamePasswordAuthenticationFilter.class); + + } +} diff --git a/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/validate/smscode/SmsAuthenticationFilter.java b/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/validate/smscode/SmsAuthenticationFilter.java new file mode 100644 index 0000000..09ac5db --- /dev/null +++ b/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/validate/smscode/SmsAuthenticationFilter.java @@ -0,0 +1,69 @@ +package cc.bnblogs.springsecurity.validate.smscode; + +import org.springframework.security.authentication.AuthenticationServiceException; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter; +import org.springframework.security.web.util.matcher.AntPathRequestMatcher; +import org.springframework.util.Assert; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +public class SmsAuthenticationFilter extends AbstractAuthenticationProcessingFilter { + + public static final String MOBILE_KEY = "mobile"; + + private String mobileParameter = MOBILE_KEY; + private boolean postOnly = true; + + + public SmsAuthenticationFilter() { + super(new AntPathRequestMatcher("/login/mobile", "POST")); + } + + + public Authentication attemptAuthentication(HttpServletRequest request, + HttpServletResponse response) throws AuthenticationException { + if (postOnly && !request.getMethod().equals("POST")) { + throw new AuthenticationServiceException( + "Authentication method not supported: " + request.getMethod()); + } + + String mobile = obtainMobile(request); + + if (mobile == null) { + mobile = ""; + } + + mobile = mobile.trim(); + + SmsAuthenticationToken authRequest = new SmsAuthenticationToken(mobile); + + setDetails(request, authRequest); + + return this.getAuthenticationManager().authenticate(authRequest); + } + + protected String obtainMobile(HttpServletRequest request) { + return request.getParameter(mobileParameter); + } + + protected void setDetails(HttpServletRequest request, + SmsAuthenticationToken authRequest) { + authRequest.setDetails(authenticationDetailsSource.buildDetails(request)); + } + + public void setMobileParameter(String mobileParameter) { + Assert.hasText(mobileParameter, "mobile parameter must not be empty or null"); + this.mobileParameter = mobileParameter; + } + + public void setPostOnly(boolean postOnly) { + this.postOnly = postOnly; + } + + public final String getMobileParameter() { + return mobileParameter; + } +} diff --git a/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/validate/smscode/SmsAuthenticationProvider.java b/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/validate/smscode/SmsAuthenticationProvider.java new file mode 100644 index 0000000..c93b940 --- /dev/null +++ b/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/validate/smscode/SmsAuthenticationProvider.java @@ -0,0 +1,37 @@ +package cc.bnblogs.springsecurity.validate.smscode; + +import cc.bnblogs.springsecurity.Service.UserDetailService; +import org.springframework.security.authentication.AuthenticationProvider; +import org.springframework.security.authentication.InternalAuthenticationServiceException; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.core.userdetails.UserDetails; + +public class SmsAuthenticationProvider implements AuthenticationProvider { + + private UserDetailService userDetailService; + + @Override + public Authentication authenticate(Authentication authentication) throws AuthenticationException { + SmsAuthenticationToken authenticationToken = (SmsAuthenticationToken) authentication; + UserDetails userDetails = userDetailService.loadUserByUsername((String) authenticationToken.getPrincipal()); + + if (userDetails == null) + throw new InternalAuthenticationServiceException("未找到与该手机号对应的用户"); + + SmsAuthenticationToken authenticationResult = new SmsAuthenticationToken(userDetails, userDetails.getAuthorities()); + + authenticationResult.setDetails(authenticationToken.getDetails()); + + return authenticationResult; + } + + @Override + public boolean supports(Class aClass) { + return SmsAuthenticationToken.class.isAssignableFrom(aClass); + } + + public void setUserDetailService(UserDetailService userDetailService) { + this.userDetailService = userDetailService; + } +} diff --git a/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/validate/smscode/SmsAuthenticationToken.java b/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/validate/smscode/SmsAuthenticationToken.java new file mode 100644 index 0000000..a48cf0a --- /dev/null +++ b/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/validate/smscode/SmsAuthenticationToken.java @@ -0,0 +1,49 @@ +package cc.bnblogs.springsecurity.validate.smscode; + +import org.springframework.security.authentication.AbstractAuthenticationToken; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.SpringSecurityCoreVersion; + +import java.util.Collection; + +public class SmsAuthenticationToken extends AbstractAuthenticationToken { + + private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID; + + private final Object principal; + + public SmsAuthenticationToken(String mobile) { + super(null); + this.principal = mobile; + setAuthenticated(false); + } + + public SmsAuthenticationToken(Object principal, Collection authorities) { + super(authorities); + this.principal = principal; + super.setAuthenticated(true); // must use super, as we override + } + + @Override + public Object getCredentials() { + return null; + } + + public Object getPrincipal() { + return this.principal; + } + + public void setAuthenticated(boolean isAuthenticated) throws IllegalArgumentException { + if (isAuthenticated) { + throw new IllegalArgumentException( + "Cannot set this token to trusted - use constructor which takes a GrantedAuthority list instead"); + } + + super.setAuthenticated(false); + } + + @Override + public void eraseCredentials() { + super.eraseCredentials(); + } +} diff --git a/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/validate/smscode/SmsCode.java b/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/validate/smscode/SmsCode.java new file mode 100644 index 0000000..69435f9 --- /dev/null +++ b/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/validate/smscode/SmsCode.java @@ -0,0 +1,40 @@ +package cc.bnblogs.springsecurity.validate.smscode; + +import java.time.LocalDateTime; + +public class SmsCode { + + private String code; + + private LocalDateTime expireTime; + + public SmsCode(String code, int expireIn) { + this.code = code; + this.expireTime = LocalDateTime.now().plusSeconds(expireIn); + } + + public SmsCode(String code, LocalDateTime expireTime) { + this.code = code; + this.expireTime = expireTime; + } + + boolean isExpire() { + return LocalDateTime.now().isAfter(expireTime); + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public LocalDateTime getExpireTime() { + return expireTime; + } + + public void setExpireTime(LocalDateTime expireTime) { + this.expireTime = expireTime; + } +} diff --git a/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/validate/smscode/SmsCodeFilter.java b/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/validate/smscode/SmsCodeFilter.java new file mode 100644 index 0000000..c84fc60 --- /dev/null +++ b/SpringSecurity/src/main/java/cc/bnblogs/springsecurity/validate/smscode/SmsCodeFilter.java @@ -0,0 +1,66 @@ +package cc.bnblogs.springsecurity.validate.smscode; + +import cc.bnblogs.springsecurity.Exception.ValidateCodeException; +import cc.bnblogs.springsecurity.controller.ValidateCodeController; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.web.authentication.AuthenticationFailureHandler; +import org.springframework.social.connect.web.HttpSessionSessionStrategy; +import org.springframework.social.connect.web.SessionStrategy; +import org.springframework.stereotype.Component; +import org.springframework.web.bind.ServletRequestBindingException; +import org.springframework.web.bind.ServletRequestUtils; +import org.springframework.web.context.request.ServletWebRequest; +import org.springframework.web.filter.OncePerRequestFilter; + +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +@Component +public class SmsCodeFilter extends OncePerRequestFilter { + + @Autowired + private AuthenticationFailureHandler authenticationFailureHandler; + + private final SessionStrategy sessionStrategy = new HttpSessionSessionStrategy(); + + @Override + protected void doFilterInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, FilterChain filterChain) throws ServletException, IOException { + if (StringUtils.equalsIgnoreCase("/login/mobile", httpServletRequest.getRequestURI()) + && StringUtils.equalsIgnoreCase(httpServletRequest.getMethod(), "post")) { + try { + validateCode(new ServletWebRequest(httpServletRequest)); + } catch (ValidateCodeException e) { + authenticationFailureHandler.onAuthenticationFailure(httpServletRequest, httpServletResponse, e); + return; + } + } + filterChain.doFilter(httpServletRequest, httpServletResponse); + } + + private void validateCode(ServletWebRequest servletWebRequest) throws ServletRequestBindingException { + String smsCodeInRequest = ServletRequestUtils.getStringParameter(servletWebRequest.getRequest(), "smsCode"); + String mobileInRequest = ServletRequestUtils.getStringParameter(servletWebRequest.getRequest(), "smsCode"); + + SmsCode codeInSession = (SmsCode) sessionStrategy.getAttribute(servletWebRequest, ValidateCodeController.SESSION_KEY_SMS_CODE + mobileInRequest); + + if (StringUtils.isBlank(smsCodeInRequest)) { + throw new ValidateCodeException("验证码不能为空!"); + } + if (codeInSession == null) { + throw new ValidateCodeException("验证码不存在!"); + } + if (codeInSession.isExpire()) { + sessionStrategy.removeAttribute(servletWebRequest, ValidateCodeController.SESSION_KEY_SMS_CODE); + throw new ValidateCodeException("验证码已过期!"); + } + if (!StringUtils.equalsIgnoreCase(codeInSession.getCode(), smsCodeInRequest)) { + throw new ValidateCodeException("验证码不正确!"); + } + sessionStrategy.removeAttribute(servletWebRequest, ValidateCodeController.SESSION_KEY_SMS_CODE); + + } +} \ No newline at end of file diff --git a/SpringSecurity/src/main/resources/application.yml b/SpringSecurity/src/main/resources/application.yml new file mode 100644 index 0000000..c5e88f3 --- /dev/null +++ b/SpringSecurity/src/main/resources/application.yml @@ -0,0 +1,6 @@ +spring: + datasource: + username: root + password: zfp251217 + url: jdbc:mysql://192.168.153.131:3306/test?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8 + driver-class-name: com.mysql.cj.jdbc.Driver diff --git a/SpringSecurity/src/main/resources/static/css/login.css b/SpringSecurity/src/main/resources/static/css/login.css new file mode 100644 index 0000000..52d1699 --- /dev/null +++ b/SpringSecurity/src/main/resources/static/css/login.css @@ -0,0 +1,97 @@ +.login-page { + width: 360px; + padding: 8% 0 0; + margin: auto; +} +.form { + position: relative; + z-index: 1; + background: #ffffff; + max-width: 360px; + margin: 0 auto 100px; + padding: 45px; + text-align: center; + box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.2), 0 5px 5px 0 rgba(0, 0, 0, 0.24); +} +.form input { + outline: 0; + background: #f2f2f2; + width: 100%; + border: 0; + margin: 0 0 15px; + padding: 15px; + box-sizing: border-box; + font-size: 14px; +} +.form button { + text-transform: uppercase; + outline: 0; + background: #4caf50; + width: 100%; + border: 0; + padding: 15px; + color: #ffffff; + font-size: 14px; + -webkit-transition: all 0.3 ease; + transition: all 0.3 ease; + cursor: pointer; +} +.form button:hover, +.form button:active, +.form button:focus { + background: #43a047; +} +.form .message { + margin: 15px 0 0; + color: #b3b3b3; + font-size: 12px; +} +.form .message a { + color: #4caf50; + text-decoration: none; +} +.form .register-form { + display: none; +} +.container { + position: relative; + z-index: 1; + max-width: 300px; + margin: 0 auto; +} +.container:before, +.container:after { + content: ""; + display: block; + clear: both; +} +.container .info { + margin: 50px auto; + text-align: center; +} +.container .info h1 { + margin: 0 0 15px; + padding: 0; + font-size: 36px; + font-weight: 300; + color: #1a1a1a; +} +.container .info span { + color: #4d4d4d; + font-size: 12px; +} +.container .info span a { + color: #000000; + text-decoration: none; +} +.container .info span .fa { + color: #ef3b3a; +} +body { + background: #76b852; /* fallback for old browsers */ + background: -webkit-linear-gradient(right, #76b852, #8dc26f); + background: -moz-linear-gradient(right, #76b852, #8dc26f); + background: -o-linear-gradient(right, #76b852, #8dc26f); + background: linear-gradient(to left, #76b852, #8dc26f); + font-family: Lato,"PingFang SC","Microsoft YaHei",sans-serif; +} diff --git a/SpringSecurity/src/main/resources/static/login.html b/SpringSecurity/src/main/resources/static/login.html new file mode 100644 index 0000000..05ea7c5 --- /dev/null +++ b/SpringSecurity/src/main/resources/static/login.html @@ -0,0 +1,37 @@ + + + + + 登录 + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SpringSecurity/src/test/java/cc/bnblogs/springsecurity/SpringSecurityApplicationTests.java b/SpringSecurity/src/test/java/cc/bnblogs/springsecurity/SpringSecurityApplicationTests.java new file mode 100644 index 0000000..4cd8ec1 --- /dev/null +++ b/SpringSecurity/src/test/java/cc/bnblogs/springsecurity/SpringSecurityApplicationTests.java @@ -0,0 +1,13 @@ +package cc.bnblogs.springsecurity; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class SpringSecurityApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/SpringTest b/SpringTest new file mode 160000 index 0000000..38c6163 --- /dev/null +++ b/SpringTest @@ -0,0 +1 @@ +Subproject commit 38c6163736df9fe58fe02e148e09c38a142a33f3 diff --git a/annotations/pom.xml b/annotations/pom.xml index 08cba9b..46e6897 100644 --- a/annotations/pom.xml +++ b/annotations/pom.xml @@ -51,6 +51,28 @@ spring-boot-starter-test test + + + + javax.validation + validation-api + + + + org.hibernate.validator + hibernate-validator + + + + org.glassfish + jakarta.el + 4.0.0 + + + + org.projectlombok + lombok + diff --git a/annotations/src/main/java/cc/bnblogs/annotations/AnnotationsApplication.java b/annotations/src/main/java/cc/bnblogs/annotations/AnnotationsApplication.java index 73cb024..59303ba 100644 --- a/annotations/src/main/java/cc/bnblogs/annotations/AnnotationsApplication.java +++ b/annotations/src/main/java/cc/bnblogs/annotations/AnnotationsApplication.java @@ -1,8 +1,11 @@ package cc.bnblogs.annotations; +import cc.bnblogs.annotations.entity.Student; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +@EnableConfigurationProperties(Student.class) @SpringBootApplication public class AnnotationsApplication { diff --git a/annotations/src/main/java/cc/bnblogs/annotations/config/ValidatorConfig.java b/annotations/src/main/java/cc/bnblogs/annotations/config/ValidatorConfig.java new file mode 100644 index 0000000..c0f41c1 --- /dev/null +++ b/annotations/src/main/java/cc/bnblogs/annotations/config/ValidatorConfig.java @@ -0,0 +1,24 @@ +package cc.bnblogs.annotations.config; + +import org.hibernate.validator.HibernateValidator; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import javax.validation.Validation; +import javax.validation.Validator; +import javax.validation.ValidatorFactory; + +@Configuration +public class ValidatorConfig { + @Bean + public Validator validator() { + ValidatorFactory validatorFactory = Validation.byProvider(HibernateValidator.class) + .configure() + // 快速失败模式 + .failFast(true) + // .addProperty( "hibernate.validator.fail_fast", "true" ) + .buildValidatorFactory(); + return validatorFactory.getValidator(); + } + +} diff --git a/annotations/src/main/java/cc/bnblogs/annotations/controller/StudentController.java b/annotations/src/main/java/cc/bnblogs/annotations/controller/StudentController.java new file mode 100644 index 0000000..acc50c4 --- /dev/null +++ b/annotations/src/main/java/cc/bnblogs/annotations/controller/StudentController.java @@ -0,0 +1,17 @@ +package cc.bnblogs.annotations.controller; + +import cc.bnblogs.annotations.entity.Student; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class StudentController { + @Autowired + private Student student; + @GetMapping("stu") + public Student getStudent() { + return student; + } + +} diff --git a/annotations/src/main/java/cc/bnblogs/annotations/entity/Student.java b/annotations/src/main/java/cc/bnblogs/annotations/entity/Student.java new file mode 100644 index 0000000..9ce297d --- /dev/null +++ b/annotations/src/main/java/cc/bnblogs/annotations/entity/Student.java @@ -0,0 +1,23 @@ +package cc.bnblogs.annotations.entity; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.validation.annotation.Validated; + +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@ConfigurationProperties(prefix = "student") +@Validated +public class Student { + private int id; + private String name; + @Max(value = 40,message = "最大值不能超过40") + @Min(value = 10,message = "最小值不能小于10") + private int age; +} diff --git a/annotations/src/main/resources/application.properties b/annotations/src/main/resources/application.properties index 3b31a60..162e728 100644 --- a/annotations/src/main/resources/application.properties +++ b/annotations/src/main/resources/application.properties @@ -18,3 +18,10 @@ local.password=admin123 #person.password=123123 #person.sex=\u7537 #person.age=18 + +# \u8BFB\u53D6\u914D\u7F6E\u6587\u4EF6\u5C5E\u6027 +student.id = 1 +student.name = admin +student.age = 30 + +bnblogs.author = barney diff --git a/annotations/src/test/java/cc/bnblogs/annotations/AnnotationsApplicationTests.java b/annotations/src/test/java/cc/bnblogs/annotations/AnnotationsApplicationTests.java index 8e9734c..e2059eb 100644 --- a/annotations/src/test/java/cc/bnblogs/annotations/AnnotationsApplicationTests.java +++ b/annotations/src/test/java/cc/bnblogs/annotations/AnnotationsApplicationTests.java @@ -1,13 +1,27 @@ package cc.bnblogs.annotations; import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.test.context.SpringBootTest; -@SpringBootTest +/** + * 测试类读取配置文件信息 + * 临时修改配置文件中的值 + * 临时属性优先级大于配置文件属性 + */ +// 方法1:在@SpringBootTest注解上添加properties属性,设置和配置文件一样的属性,并设置值(优先级比@Value高) +// 方法2:在@SpringBootTest注解上添加args的参数,并设置值--bnblogs.author=admin +// 如果同时设置了两种参数,将使用properties设置的值 +//@SpringBootTest(properties = "bnblogs.author=tom") +@SpringBootTest(args = "--bnblogs.author=admin",properties = "bnblogs.author=tom") class AnnotationsApplicationTests { + @Value("${bnblogs.author}") + private String blogAuthor; + @Test void contextLoads() { + System.out.println(blogAuthor); } } diff --git a/beanStudy/.gitignore b/beanStudy/.gitignore new file mode 100644 index 0000000..549e00a --- /dev/null +++ b/beanStudy/.gitignore @@ -0,0 +1,33 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ diff --git a/beanStudy/.mvn/wrapper/maven-wrapper.jar b/beanStudy/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 0000000..bf82ff0 Binary files /dev/null and b/beanStudy/.mvn/wrapper/maven-wrapper.jar differ diff --git a/beanStudy/.mvn/wrapper/maven-wrapper.properties b/beanStudy/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..ca5ab4b --- /dev/null +++ b/beanStudy/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar diff --git a/beanStudy/mvnw b/beanStudy/mvnw new file mode 100644 index 0000000..8a8fb22 --- /dev/null +++ b/beanStudy/mvnw @@ -0,0 +1,316 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /usr/local/etc/mavenrc ] ; then + . /usr/local/etc/mavenrc + fi + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`\\unset -f command; \\command -v java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + fi + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=`cygpath --path --windows "$javaClass"` + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + $MAVEN_DEBUG_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" \ + "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/beanStudy/mvnw.cmd b/beanStudy/mvnw.cmd new file mode 100644 index 0000000..1d8ab01 --- /dev/null +++ b/beanStudy/mvnw.cmd @@ -0,0 +1,188 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* +if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + +FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% ^ + %JVM_CONFIG_MAVEN_PROPS% ^ + %MAVEN_OPTS% ^ + %MAVEN_DEBUG_OPTS% ^ + -classpath %WRAPPER_JAR% ^ + "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ + %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" +if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%"=="on" pause + +if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% + +cmd /C exit /B %ERROR_CODE% diff --git a/beanStudy/pom.xml b/beanStudy/pom.xml new file mode 100644 index 0000000..f0ff94c --- /dev/null +++ b/beanStudy/pom.xml @@ -0,0 +1,60 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.7.10 + + + cc.bnblogs + beanStudy + 0.0.1-SNAPSHOT + beanStudy + beanStudy + + 1.8 + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-devtools + runtime + true + + + org.projectlombok + lombok + true + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + org.projectlombok + lombok + + + + + + + + diff --git a/beanStudy/src/main/java/cc/bnblogs/beanstudy/BeanStudyApplication.java b/beanStudy/src/main/java/cc/bnblogs/beanstudy/BeanStudyApplication.java new file mode 100644 index 0000000..600322a --- /dev/null +++ b/beanStudy/src/main/java/cc/bnblogs/beanstudy/BeanStudyApplication.java @@ -0,0 +1,13 @@ +package cc.bnblogs.beanstudy; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class BeanStudyApplication { + + public static void main(String[] args) { + SpringApplication.run(BeanStudyApplication.class, args); + } + +} diff --git a/beanStudy/src/main/java/cc/bnblogs/beanstudy/bean/MyBeanInstantiationPostProcessor.java b/beanStudy/src/main/java/cc/bnblogs/beanstudy/bean/MyBeanInstantiationPostProcessor.java new file mode 100644 index 0000000..3f6ca50 --- /dev/null +++ b/beanStudy/src/main/java/cc/bnblogs/beanstudy/bean/MyBeanInstantiationPostProcessor.java @@ -0,0 +1,35 @@ +package cc.bnblogs.beanstudy.bean; + +import org.springframework.beans.BeansException; +import org.springframework.beans.PropertyValues; +import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor; +import org.springframework.stereotype.Component; + + +@Component +public class MyBeanInstantiationPostProcessor implements InstantiationAwareBeanPostProcessor { + + @Override + public Object postProcessBeforeInstantiation(Class beanClass, String beanName) throws BeansException { + if ("beanStudyApplication".equals(beanName)) { + System.out.println("post process before " + beanName + " instantiation"); + } + return null; + } + + @Override + public boolean postProcessAfterInstantiation(Object bean, String beanName) throws BeansException { + if ("beanStudyApplication".equals(beanName)) { + System.out.println("post process after " + beanName + " instantiation"); + } + return true; + } + + @Override + public PropertyValues postProcessProperties(PropertyValues pvs, Object bean, String beanName) throws BeansException { + if ("beanStudyApplication".equals(beanName)) { + System.out.println("post process " + beanName + " properties"); + } + return pvs; + } +} \ No newline at end of file diff --git a/beanStudy/src/main/java/cc/bnblogs/beanstudy/bean/MyBeanPostProcessor.java b/beanStudy/src/main/java/cc/bnblogs/beanstudy/bean/MyBeanPostProcessor.java new file mode 100644 index 0000000..cc3082b --- /dev/null +++ b/beanStudy/src/main/java/cc/bnblogs/beanstudy/bean/MyBeanPostProcessor.java @@ -0,0 +1,17 @@ +package cc.bnblogs.beanstudy.bean; + +import org.springframework.beans.BeansException; +import org.springframework.beans.factory.config.BeanPostProcessor; + +public class MyBeanPostProcessor implements BeanPostProcessor { + @Override + public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { + System.out.println(beanName + " 初始化之前调用"); + return bean; + } + @Override + public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { + System.out.println(beanName + " 初始化之后调用"); + return bean; + } +} \ No newline at end of file diff --git a/beanStudy/src/main/java/cc/bnblogs/beanstudy/bean/MyOtherBeanPostProcessor.java b/beanStudy/src/main/java/cc/bnblogs/beanstudy/bean/MyOtherBeanPostProcessor.java new file mode 100644 index 0000000..ba3c2e5 --- /dev/null +++ b/beanStudy/src/main/java/cc/bnblogs/beanstudy/bean/MyOtherBeanPostProcessor.java @@ -0,0 +1,31 @@ +package cc.bnblogs.beanstudy.bean; + +import org.springframework.beans.BeansException; +import org.springframework.beans.factory.config.BeanPostProcessor; +import org.springframework.stereotype.Component; + +/** + * @description: + * @author: zfp@bnblogs.cc + * @date: 2023/3/28 23:38 + */ +@Component +public class MyOtherBeanPostProcessor implements BeanPostProcessor { + + @Override + public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { + if ("beanStudyApplication".equals(beanName)) { + System.out.println("post processor before " + beanName + " initialization"); + } + return bean; + } + + @Override + public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { + if ("beanStudyApplication".equals(beanName)) { + System.out.println("post processor after " + beanName + " initialization"); + } + return bean; + } + +} \ No newline at end of file diff --git a/beanStudy/src/main/java/cc/bnblogs/beanstudy/bean/WebConfig.java b/beanStudy/src/main/java/cc/bnblogs/beanstudy/bean/WebConfig.java new file mode 100644 index 0000000..15e4c71 --- /dev/null +++ b/beanStudy/src/main/java/cc/bnblogs/beanstudy/bean/WebConfig.java @@ -0,0 +1,37 @@ +package cc.bnblogs.beanstudy.bean; + +import cc.bnblogs.beanstudy.entity.Bird; +import cc.bnblogs.beanstudy.entity.Fish; +import cc.bnblogs.beanstudy.entity.User; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Scope; + +/** + * @description: + * @author: zfp@bnblogs.cc + * @date: 2023/3/28 23:04 + */ +@Configuration +public class WebConfig { +// @Bean(initMethod = "init",destroyMethod = "destroy") +//// @Scope(value = "prototype") +// public User user() { +// return new User(); +// } + + @Bean + public Bird bird() { + return new Bird(); + } + + @Bean + public Fish fish() { + return new Fish(); + } + +// @Bean +// public MyBeanPostProcessor myBeanPostProcessor () { +// return new MyBeanPostProcessor(); +// } +} diff --git a/beanStudy/src/main/java/cc/bnblogs/beanstudy/entity/Bird.java b/beanStudy/src/main/java/cc/bnblogs/beanstudy/entity/Bird.java new file mode 100644 index 0000000..e20f64d --- /dev/null +++ b/beanStudy/src/main/java/cc/bnblogs/beanstudy/entity/Bird.java @@ -0,0 +1,20 @@ +package cc.bnblogs.beanstudy.entity; + +import org.springframework.beans.factory.DisposableBean; +import org.springframework.beans.factory.InitializingBean; + +public class Bird implements InitializingBean, DisposableBean { + public Bird() { + System.out.println("调用无参构造器创建Bird"); + } + + @Override + public void destroy() { + System.out.println("销毁Bird"); + } + + @Override + public void afterPropertiesSet() { + System.out.println("初始化Bird"); + } +} \ No newline at end of file diff --git a/beanStudy/src/main/java/cc/bnblogs/beanstudy/entity/Fish.java b/beanStudy/src/main/java/cc/bnblogs/beanstudy/entity/Fish.java new file mode 100644 index 0000000..a7f6a97 --- /dev/null +++ b/beanStudy/src/main/java/cc/bnblogs/beanstudy/entity/Fish.java @@ -0,0 +1,26 @@ +package cc.bnblogs.beanstudy.entity; + +import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; + +public class Fish { + public Fish() { + System.out.println("调用无参构造器创建Fish"); + } + + /** + * 初始化方法 + */ + @PostConstruct + public void init() { + System.out.println("初始化Fish"); + } + + /** + * 销毁方法 + */ + @PreDestroy + public void destroy() { + System.out.println("销毁Fish"); + } +} \ No newline at end of file diff --git a/beanStudy/src/main/java/cc/bnblogs/beanstudy/entity/User.java b/beanStudy/src/main/java/cc/bnblogs/beanstudy/entity/User.java new file mode 100644 index 0000000..3f8f207 --- /dev/null +++ b/beanStudy/src/main/java/cc/bnblogs/beanstudy/entity/User.java @@ -0,0 +1,21 @@ +package cc.bnblogs.beanstudy.entity; + +import lombok.Data; + +/** + * @description: + * @author: zfp@bnblogs.cc + * @date: 2023/3/28 23:05 + */ +@Data +public class User { + public User() { + System.out.println("调用无参构造器创建User"); + } + public void init() { + System.out.println("初始化User"); + } + public void destroy() { + System.out.println("销毁User"); + } +} \ No newline at end of file diff --git a/beanStudy/src/main/resources/application.properties b/beanStudy/src/main/resources/application.properties new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/beanStudy/src/main/resources/application.properties @@ -0,0 +1 @@ + diff --git a/beanStudy/src/test/java/cc/bnblogs/beanstudy/BeanStudyApplicationTests.java b/beanStudy/src/test/java/cc/bnblogs/beanstudy/BeanStudyApplicationTests.java new file mode 100644 index 0000000..bc80595 --- /dev/null +++ b/beanStudy/src/test/java/cc/bnblogs/beanstudy/BeanStudyApplicationTests.java @@ -0,0 +1,13 @@ +package cc.bnblogs.beanstudy; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class BeanStudyApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/beanStudy/src/test/java/cc/bnblogs/beanstudy/bean/WebConfigTest.java b/beanStudy/src/test/java/cc/bnblogs/beanstudy/bean/WebConfigTest.java new file mode 100644 index 0000000..7f4e27c --- /dev/null +++ b/beanStudy/src/test/java/cc/bnblogs/beanstudy/bean/WebConfigTest.java @@ -0,0 +1,58 @@ +package cc.bnblogs.beanstudy.bean; + +import cc.bnblogs.beanstudy.entity.Bird; +import cc.bnblogs.beanstudy.entity.Fish; +import cc.bnblogs.beanstudy.entity.User; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.AnnotationConfigApplicationContext; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * @description: + * @author: zfp@bnblogs.cc + * @date: 2023/3/28 23:07 + */ +@SpringBootTest +public class WebConfigTest { + + /** + * 单例模式下: + * 在容器启动之前,先调用对象的无参构造器创建对象,然后调用初始化方法, + * 在容器关闭的时候调用销毁方法 + */ + + /** + * 多例模式: + * IOC容器启动的时候并不会去创建对象,而是在每次获取的时候才会去调用方法创建对象, + * 创建完对象后再调用初始化方法。但在容器关闭后,Spring并没有调用相应的销毁方法, + * 这是因为在多例模式下,容器不会管理这个组件(只在需要时帮你创建这个组件) + */ + @Test + void testBean() { + // 返回 IOC 容器,使用注解配置,传入配置类 + AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(WebConfig.class); + User user = context.getBean(User.class); + System.out.println(user); + // 关闭 IOC 容器 + context.close(); + } + + @Test + void testBird() { + AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(WebConfig.class); + System.out.println("容器创建成功"); + Bird bird = context.getBean(Bird.class); + context.close(); + } + + @Test + void testFish() { + AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(WebConfig.class); + System.out.println("容器创建成功"); + Fish fish = context.getBean(Fish.class); + context.close(); + } +} \ No newline at end of file diff --git a/elasticSearchDemo/.gitignore b/elasticSearchDemo/.gitignore new file mode 100644 index 0000000..549e00a --- /dev/null +++ b/elasticSearchDemo/.gitignore @@ -0,0 +1,33 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ diff --git a/elasticSearchDemo/.mvn/wrapper/maven-wrapper.jar b/elasticSearchDemo/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 0000000..bf82ff0 Binary files /dev/null and b/elasticSearchDemo/.mvn/wrapper/maven-wrapper.jar differ diff --git a/elasticSearchDemo/.mvn/wrapper/maven-wrapper.properties b/elasticSearchDemo/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..ca5ab4b --- /dev/null +++ b/elasticSearchDemo/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar diff --git a/elasticSearchDemo/mvnw b/elasticSearchDemo/mvnw new file mode 100644 index 0000000..8a8fb22 --- /dev/null +++ b/elasticSearchDemo/mvnw @@ -0,0 +1,316 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /usr/local/etc/mavenrc ] ; then + . /usr/local/etc/mavenrc + fi + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`\\unset -f command; \\command -v java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + fi + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=`cygpath --path --windows "$javaClass"` + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + $MAVEN_DEBUG_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" \ + "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/elasticSearchDemo/mvnw.cmd b/elasticSearchDemo/mvnw.cmd new file mode 100644 index 0000000..1d8ab01 --- /dev/null +++ b/elasticSearchDemo/mvnw.cmd @@ -0,0 +1,188 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* +if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + +FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% ^ + %JVM_CONFIG_MAVEN_PROPS% ^ + %MAVEN_OPTS% ^ + %MAVEN_DEBUG_OPTS% ^ + -classpath %WRAPPER_JAR% ^ + "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ + %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" +if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%"=="on" pause + +if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% + +cmd /C exit /B %ERROR_CODE% diff --git a/elasticSearchDemo/pom.xml b/elasticSearchDemo/pom.xml new file mode 100644 index 0000000..6ff88d7 --- /dev/null +++ b/elasticSearchDemo/pom.xml @@ -0,0 +1,71 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.7.11 + + + cc.bnblogs + elasticSearchDemo + 0.0.1-SNAPSHOT + elasticSearchDemo + elasticSearchDemo + + 1.8 + + + + org.springframework.boot + spring-boot-starter-web + + + + org.elasticsearch + elasticsearch + 7.8.0 + + + + org.elasticsearch.client + elasticsearch-rest-high-level-client + 7.8.0 + + + + org.springframework.boot + spring-boot-devtools + + + + org.projectlombok + lombok + true + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + org.projectlombok + lombok + + + + + + + + diff --git a/elasticSearchDemo/src/main/java/cc/bnblogs/elasticsearchdemo/ElasticSearchDemoApplication.java b/elasticSearchDemo/src/main/java/cc/bnblogs/elasticsearchdemo/ElasticSearchDemoApplication.java new file mode 100644 index 0000000..2674f94 --- /dev/null +++ b/elasticSearchDemo/src/main/java/cc/bnblogs/elasticsearchdemo/ElasticSearchDemoApplication.java @@ -0,0 +1,13 @@ +package cc.bnblogs.elasticsearchdemo; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class ElasticSearchDemoApplication { + + public static void main(String[] args) { + SpringApplication.run(ElasticSearchDemoApplication.class, args); + } + +} diff --git a/elasticSearchDemo/src/main/resources/application.yml b/elasticSearchDemo/src/main/resources/application.yml new file mode 100644 index 0000000..e69de29 diff --git a/elasticSearchDemo/src/test/java/cc/bnblogs/elasticsearchdemo/ElasticSearchDemoApplicationTests.java b/elasticSearchDemo/src/test/java/cc/bnblogs/elasticsearchdemo/ElasticSearchDemoApplicationTests.java new file mode 100644 index 0000000..ab372f7 --- /dev/null +++ b/elasticSearchDemo/src/test/java/cc/bnblogs/elasticsearchdemo/ElasticSearchDemoApplicationTests.java @@ -0,0 +1,13 @@ +package cc.bnblogs.elasticsearchdemo; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class ElasticSearchDemoApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/kafkaStudy/.gitignore b/kafkaStudy/.gitignore new file mode 100644 index 0000000..549e00a --- /dev/null +++ b/kafkaStudy/.gitignore @@ -0,0 +1,33 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ diff --git a/kafkaStudy/.mvn/wrapper/maven-wrapper.jar b/kafkaStudy/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 0000000..bf82ff0 Binary files /dev/null and b/kafkaStudy/.mvn/wrapper/maven-wrapper.jar differ diff --git a/kafkaStudy/.mvn/wrapper/maven-wrapper.properties b/kafkaStudy/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..ca5ab4b --- /dev/null +++ b/kafkaStudy/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar diff --git a/kafkaStudy/mvnw b/kafkaStudy/mvnw new file mode 100644 index 0000000..8a8fb22 --- /dev/null +++ b/kafkaStudy/mvnw @@ -0,0 +1,316 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /usr/local/etc/mavenrc ] ; then + . /usr/local/etc/mavenrc + fi + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`\\unset -f command; \\command -v java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + fi + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=`cygpath --path --windows "$javaClass"` + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + $MAVEN_DEBUG_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" \ + "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/kafkaStudy/mvnw.cmd b/kafkaStudy/mvnw.cmd new file mode 100644 index 0000000..1d8ab01 --- /dev/null +++ b/kafkaStudy/mvnw.cmd @@ -0,0 +1,188 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* +if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + +FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% ^ + %JVM_CONFIG_MAVEN_PROPS% ^ + %MAVEN_OPTS% ^ + %MAVEN_DEBUG_OPTS% ^ + -classpath %WRAPPER_JAR% ^ + "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ + %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" +if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%"=="on" pause + +if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% + +cmd /C exit /B %ERROR_CODE% diff --git a/kafkaStudy/pom.xml b/kafkaStudy/pom.xml new file mode 100644 index 0000000..4f640b6 --- /dev/null +++ b/kafkaStudy/pom.xml @@ -0,0 +1,60 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.7.10 + + + cc.bnblogs + kafkaStudy + 0.0.1-SNAPSHOT + kafkaStudy + kafkaStudy + + 1.8 + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-devtools + runtime + true + + + org.projectlombok + lombok + true + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + org.projectlombok + lombok + + + + + + + + diff --git a/kafkaStudy/src/main/java/cc/bnblogs/kafkastudy/KafkaStudyApplication.java b/kafkaStudy/src/main/java/cc/bnblogs/kafkastudy/KafkaStudyApplication.java new file mode 100644 index 0000000..5a3c35b --- /dev/null +++ b/kafkaStudy/src/main/java/cc/bnblogs/kafkastudy/KafkaStudyApplication.java @@ -0,0 +1,13 @@ +package cc.bnblogs.kafkastudy; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class KafkaStudyApplication { + + public static void main(String[] args) { + SpringApplication.run(KafkaStudyApplication.class, args); + } + +} diff --git a/kafkaStudy/src/main/resources/application.properties b/kafkaStudy/src/main/resources/application.properties new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/kafkaStudy/src/main/resources/application.properties @@ -0,0 +1 @@ + diff --git a/kafkaStudy/src/test/java/cc/bnblogs/kafkastudy/KafkaStudyApplicationTests.java b/kafkaStudy/src/test/java/cc/bnblogs/kafkastudy/KafkaStudyApplicationTests.java new file mode 100644 index 0000000..f791154 --- /dev/null +++ b/kafkaStudy/src/test/java/cc/bnblogs/kafkastudy/KafkaStudyApplicationTests.java @@ -0,0 +1,13 @@ +package cc.bnblogs.kafkastudy; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class KafkaStudyApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/springmvcdemo/.idea/encodings.xml b/springmvcdemo/.idea/encodings.xml index aa00ffa..63574ec 100644 --- a/springmvcdemo/.idea/encodings.xml +++ b/springmvcdemo/.idea/encodings.xml @@ -1,7 +1,8 @@ - + + \ No newline at end of file diff --git a/springmvcdemo/src/main/java/cc/bnblogs/controller/DataHandler.java b/springmvcdemo/src/main/java/cc/bnblogs/controller/DataHandler.java index b920130..ac4818b 100644 --- a/springmvcdemo/src/main/java/cc/bnblogs/controller/DataHandler.java +++ b/springmvcdemo/src/main/java/cc/bnblogs/controller/DataHandler.java @@ -43,7 +43,7 @@ public class DataHandler { */ @RequestMapping(value = "list",method = RequestMethod.POST) public String list(UserList userList) { -// System.out.println(userList); // 输出list中的数据 + System.out.println(userList); // 输出list中的数据 StringBuilder str = new StringBuilder(); for (User user : userList.getUsers()) { str.append(user); diff --git a/springmvcdemo/src/main/resources/springmvc.xml b/springmvcdemo/src/main/resources/springmvc.xml index b348eb0..b7a27a1 100644 --- a/springmvcdemo/src/main/resources/springmvc.xml +++ b/springmvcdemo/src/main/resources/springmvc.xml @@ -53,5 +53,6 @@ + \ No newline at end of file diff --git a/springmvcdemo/target/classes/cc/bnblogs/controller/DataHandler.class b/springmvcdemo/target/classes/cc/bnblogs/controller/DataHandler.class index 62b0976..42b7d1f 100644 Binary files a/springmvcdemo/target/classes/cc/bnblogs/controller/DataHandler.class and b/springmvcdemo/target/classes/cc/bnblogs/controller/DataHandler.class differ diff --git a/springmvcdemo/target/classes/springmvc.xml b/springmvcdemo/target/classes/springmvc.xml index b348eb0..b7a27a1 100644 --- a/springmvcdemo/target/classes/springmvc.xml +++ b/springmvcdemo/target/classes/springmvc.xml @@ -53,5 +53,6 @@ + \ No newline at end of file diff --git a/springmvcdemo/target/springmvcdemo.war b/springmvcdemo/target/springmvcdemo.war index 7ef94bf..c8d0f14 100644 Binary files a/springmvcdemo/target/springmvcdemo.war and b/springmvcdemo/target/springmvcdemo.war differ diff --git a/springmvcdemo/target/springmvcdemo/META-INF/MANIFEST.MF b/springmvcdemo/target/springmvcdemo/META-INF/MANIFEST.MF index b13588b..1eeacae 100644 --- a/springmvcdemo/target/springmvcdemo/META-INF/MANIFEST.MF +++ b/springmvcdemo/target/springmvcdemo/META-INF/MANIFEST.MF @@ -1,5 +1,5 @@ Manifest-Version: 1.0 Created-By: IntelliJ IDEA -Built-By: 15270 -Build-Jdk: 1.8.0_342 +Built-By: zfp +Build-Jdk: Oracle OpenJDK version 1.8.0_201 diff --git a/springmvcdemo/target/springmvcdemo/WEB-INF/classes/cc/bnblogs/controller/DataHandler.class b/springmvcdemo/target/springmvcdemo/WEB-INF/classes/cc/bnblogs/controller/DataHandler.class index 62b0976..42b7d1f 100644 Binary files a/springmvcdemo/target/springmvcdemo/WEB-INF/classes/cc/bnblogs/controller/DataHandler.class and b/springmvcdemo/target/springmvcdemo/WEB-INF/classes/cc/bnblogs/controller/DataHandler.class differ diff --git a/springmvcdemo/target/springmvcdemo/WEB-INF/classes/springmvc.xml b/springmvcdemo/target/springmvcdemo/WEB-INF/classes/springmvc.xml index b348eb0..b7a27a1 100644 --- a/springmvcdemo/target/springmvcdemo/WEB-INF/classes/springmvc.xml +++ b/springmvcdemo/target/springmvcdemo/WEB-INF/classes/springmvc.xml @@ -53,5 +53,6 @@ + \ No newline at end of file diff --git a/swagger_study/pom.xml b/swagger_study/pom.xml index e844dfd..8eb6a83 100644 --- a/swagger_study/pom.xml +++ b/swagger_study/pom.xml @@ -40,8 +40,6 @@ 1.6.14 - - org.springframework.boot spring-boot-devtools diff --git a/swagger_study/src/main/java/cc/bnblogs/swagger_study/controller/HelloController.java b/swagger_study/src/main/java/cc/bnblogs/swagger_study/controller/HelloController.java index d343bc1..b96e358 100644 --- a/swagger_study/src/main/java/cc/bnblogs/swagger_study/controller/HelloController.java +++ b/swagger_study/src/main/java/cc/bnblogs/swagger_study/controller/HelloController.java @@ -1,9 +1,7 @@ package cc.bnblogs.swagger_study.controller; -import io.swagger.v3.oas.annotations.Parameter; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; /**