-
Notifications
You must be signed in to change notification settings - Fork 14
feature: upgrade to Java 17 and Spring Boot 3.2.5 #985
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: base/ankehao-master
Are you sure you want to change the base?
Changes from all commits
957385e
d23be51
4a60c0d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,20 @@ | ||
| plugins { | ||
| id 'org.springframework.boot' version '2.6.3' | ||
| id 'io.spring.dependency-management' version '1.0.11.RELEASE' | ||
| id 'org.springframework.boot' version '3.2.5' | ||
| id 'io.spring.dependency-management' version '1.1.4' | ||
| id 'java' | ||
| id "com.netflix.dgs.codegen" version "5.0.6" | ||
| id "com.diffplug.spotless" version "6.2.1" | ||
| id "com.netflix.dgs.codegen" version "6.0.3" | ||
| id "com.diffplug.spotless" version "6.25.0" | ||
| } | ||
|
|
||
| version = '0.0.1-SNAPSHOT' | ||
| sourceCompatibility = '11' | ||
| targetCompatibility = '11' | ||
| sourceCompatibility = '17' | ||
| targetCompatibility = '17' | ||
|
|
||
| spotless { | ||
| java { | ||
| target project.fileTree(project.rootDir) { | ||
| include '**/*.java' | ||
| exclude 'build/generated/**/*.*', 'build/generated-examples/**/*.*' | ||
| exclude 'build/**', 'frontend/**' | ||
| } | ||
| googleJavaFormat() | ||
| } | ||
|
|
@@ -35,25 +35,25 @@ dependencies { | |
| implementation 'org.springframework.boot:spring-boot-starter-validation' | ||
| implementation 'org.springframework.boot:spring-boot-starter-hateoas' | ||
| implementation 'org.springframework.boot:spring-boot-starter-security' | ||
| implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:2.2.2' | ||
| implementation 'com.netflix.graphql.dgs:graphql-dgs-spring-boot-starter:4.9.21' | ||
| implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:3.0.3' | ||
| implementation 'com.netflix.graphql.dgs:graphql-dgs-spring-boot-starter:8.5.8' | ||
| implementation 'org.flywaydb:flyway-core' | ||
| implementation 'io.jsonwebtoken:jjwt-api:0.11.2' | ||
| runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.2', | ||
| 'io.jsonwebtoken:jjwt-jackson:0.11.2' | ||
| implementation 'joda-time:joda-time:2.10.13' | ||
| implementation 'org.xerial:sqlite-jdbc:3.36.0.3' | ||
| implementation 'io.jsonwebtoken:jjwt-api:0.11.5' | ||
| runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.5', | ||
| 'io.jsonwebtoken:jjwt-jackson:0.11.5' | ||
| implementation 'joda-time:joda-time:2.12.7' | ||
| implementation 'org.xerial:sqlite-jdbc:3.45.3.0' | ||
|
|
||
| compileOnly 'org.projectlombok:lombok' | ||
| annotationProcessor 'org.projectlombok:lombok' | ||
|
|
||
| testImplementation 'io.rest-assured:rest-assured:4.5.1' | ||
| testImplementation 'io.rest-assured:json-path:4.5.1' | ||
| testImplementation 'io.rest-assured:xml-path:4.5.1' | ||
| testImplementation 'io.rest-assured:spring-mock-mvc:4.5.1' | ||
| testImplementation 'io.rest-assured:rest-assured:5.4.0' | ||
| testImplementation 'io.rest-assured:json-path:5.4.0' | ||
| testImplementation 'io.rest-assured:xml-path:5.4.0' | ||
| testImplementation 'io.rest-assured:spring-mock-mvc:5.4.0' | ||
| testImplementation 'org.springframework.security:spring-security-test' | ||
| testImplementation 'org.springframework.boot:spring-boot-starter-test' | ||
| testImplementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter-test:2.2.2' | ||
| testImplementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter-test:3.0.3' | ||
| } | ||
|
|
||
| tasks.named('test') { | ||
|
|
@@ -69,4 +69,5 @@ tasks.named('clean') { | |
| tasks.named('generateJava') { | ||
| schemaPaths = ["${projectDir}/src/main/resources/schema"] // List of directories containing schema files | ||
| packageName = 'io.spring.graphql' // The package name to use to generate sources | ||
| typeMapping = ["PageInfo": "graphql.relay.PageInfo"] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔍 PageInfo type mapping relies on graphql.relay.PageInfo field coercion Mapping the schema Was this helpful? React with 👍 or 👎 to provide feedback. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Verified against the running app on the upgraded stack — Relay coercion still works with the graphql-java bundled by DGS 8.5.8: |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| distributionBase=GRADLE_USER_HOME | ||
| distributionPath=wrapper/dists | ||
| distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip | ||
| distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip | ||
| zipStoreBase=GRADLE_USER_HOME | ||
| zipStorePath=wrapper/dists |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,19 @@ | ||
| package io.spring.api.security; | ||
|
|
||
| import static java.util.Arrays.asList; | ||
| import static org.springframework.security.config.Customizer.withDefaults; | ||
|
|
||
| import jakarta.servlet.DispatcherType; | ||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
| import org.springframework.http.HttpMethod; | ||
| import org.springframework.http.HttpStatus; | ||
| import org.springframework.security.config.annotation.web.builders.HttpSecurity; | ||
| import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; | ||
| import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; | ||
| import org.springframework.security.config.http.SessionCreationPolicy; | ||
| import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; | ||
| import org.springframework.security.crypto.password.PasswordEncoder; | ||
| import org.springframework.security.web.SecurityFilterChain; | ||
| import org.springframework.security.web.authentication.HttpStatusEntryPoint; | ||
| import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; | ||
| import org.springframework.web.cors.CorsConfiguration; | ||
|
|
@@ -20,7 +22,7 @@ | |
|
|
||
| @Configuration | ||
| @EnableWebSecurity | ||
| public class WebSecurityConfig extends WebSecurityConfigurerAdapter { | ||
| public class WebSecurityConfig { | ||
|
|
||
| @Bean | ||
| public JwtTokenFilter jwtTokenFilter() { | ||
|
Comment on lines
27
to
28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 Info: JwtTokenFilter bean is still auto-registered in the servlet chain
Was this helpful? React with 👍 or 👎 to provide feedback. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pre-existing behavior that this upgrade doesn't change, and disabling the auto-registration would alter runtime behavior beyond the scope of the upgrade, so leaving it as-is. Worth a follow-up if the maintainers want the filter confined to the security chain. |
||
|
|
@@ -32,36 +34,38 @@ public PasswordEncoder passwordEncoder() { | |
| return new BCryptPasswordEncoder(); | ||
| } | ||
|
|
||
| @Override | ||
| protected void configure(HttpSecurity http) throws Exception { | ||
|
|
||
| http.csrf() | ||
| .disable() | ||
| .cors() | ||
| .and() | ||
| .exceptionHandling() | ||
| .authenticationEntryPoint(new HttpStatusEntryPoint(HttpStatus.UNAUTHORIZED)) | ||
| .and() | ||
| .sessionManagement() | ||
| .sessionCreationPolicy(SessionCreationPolicy.STATELESS) | ||
| .and() | ||
| .authorizeRequests() | ||
| .antMatchers(HttpMethod.OPTIONS) | ||
| .permitAll() | ||
| .antMatchers("/graphiql") | ||
| .permitAll() | ||
| .antMatchers("/graphql") | ||
| .permitAll() | ||
| .antMatchers(HttpMethod.GET, "/articles/feed") | ||
| .authenticated() | ||
| .antMatchers(HttpMethod.POST, "/users", "/users/login") | ||
| .permitAll() | ||
| .antMatchers(HttpMethod.GET, "/articles/**", "/profiles/**", "/tags") | ||
| .permitAll() | ||
| .anyRequest() | ||
| .authenticated(); | ||
| @Bean | ||
| public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { | ||
| http.csrf(csrf -> csrf.disable()) | ||
| .cors(withDefaults()) | ||
| .exceptionHandling( | ||
| exceptions -> | ||
| exceptions.authenticationEntryPoint( | ||
| new HttpStatusEntryPoint(HttpStatus.UNAUTHORIZED))) | ||
| .sessionManagement( | ||
| session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) | ||
| .authorizeHttpRequests( | ||
| requests -> | ||
| requests | ||
| .dispatcherTypeMatchers(DispatcherType.ERROR) | ||
| .permitAll() | ||
|
Comment on lines
+50
to
+51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 Info: Permitting ERROR dispatch bypasses authorization for error responses
Was this helpful? React with 👍 or 👎 to provide feedback. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Confirmed: the app has no custom error controller or |
||
| .requestMatchers(HttpMethod.OPTIONS, "/**") | ||
| .permitAll() | ||
| .requestMatchers("/graphiql", "/graphiql/**") | ||
| .permitAll() | ||
| .requestMatchers("/graphql") | ||
| .permitAll() | ||
| .requestMatchers(HttpMethod.GET, "/articles/feed") | ||
| .authenticated() | ||
| .requestMatchers(HttpMethod.POST, "/users", "/users/login") | ||
| .permitAll() | ||
| .requestMatchers(HttpMethod.GET, "/articles/**", "/profiles/**", "/tags") | ||
| .permitAll() | ||
|
Comment on lines
+52
to
+63
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 Info: requestMatchers now resolve as MvcRequestMatcher instead of Ant matchers Replacing Was this helpful? React with 👍 or 👎 to provide feedback. |
||
| .anyRequest() | ||
| .authenticated()) | ||
|
devin-ai-integration[bot] marked this conversation as resolved.
Comment on lines
+52
to
+65
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 Info: Security rule ordering and matcher semantics preserved in the DSL migration I verified the rewritten chain is semantically equivalent to the old one: Was this helpful? React with 👍 or 👎 to provide feedback. |
||
| .addFilterBefore(jwtTokenFilter(), UsernamePasswordAuthenticationFilter.class); | ||
|
|
||
| http.addFilterBefore(jwtTokenFilter(), UsernamePasswordAuthenticationFilter.class); | ||
| return http.build(); | ||
| } | ||
|
|
||
| @Bean | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Info: Spotless target now skips all Java under build/ and frontend/
The exclude was broadened from the two generated-source directories to
build/**andfrontend/**.frontend/currently contains no Java files, so the only practical effect is that DGS-generated sources underbuild/generated*are no longer formatted (as before) plus any future build outputs — no behavioral risk, but thefrontend/**exclusion is currently a no-op.Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right —
frontend/**is defensive only.build/**is the load-bearing part: under Gradle 8 scanningbuild/madespotlessJavaconsumeprocessResourcesoutput and fail the implicit-dependency check.