-
Notifications
You must be signed in to change notification settings - Fork 40.7k
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
There is no possibility to disable filtering out configuration-processor jar from spring-boot-maven plugin #27697
Comments
Relates to #22036 |
@stepanovdg Using |
If we do want to make things configurable we could either offer a simple on/off switch or change Interestingly the |
@philwebb Not sure that we really used it directly. Maybe some problem with order. I was thinking just after major update of spring versions something was broken in configuration or third-party dependency versions and this was just masking actual reason. But putting jar on classpath resolved all problems. |
@stepanovdg Do you have a full stack-trace that you can add to this issue? Even better would be a sample application that replicates the problem. I'm curious why |
Actual stacktrace. .sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and() specifically pointing to this @Override
@Log(Log.LoggingLevel.INFO)
protected void configure(HttpSecurity http) {
HashSet<String> skipUrls =
new HashSet<>(Arrays.asList("/management/health", "/management/prometheus"));
HttpSecurity httpSecurity = registerSecuredApi(http);
httpSecurity
.csrf()
.disable()
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.addFilterBefore(
new AuthenticationFilter(whitelistedIps, skipUrls),
UsernamePasswordAuthenticationFilter.class)
.addFilterBefore(new InitiatedFilter(skipUrls), AuthenticationFilter.class)
.exceptionHandling()
.authenticationEntryPoint(exceptionHandler)
.accessDeniedHandler(exceptionHandler);
}
@Log(Log.LoggingLevel.INFO)
protected HttpSecurity registerSecuredApi(HttpSecurity http) throws Exception {
ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry
expressionInterceptUrlRegistry = http.authorizeRequests();
Map<HttpMethod, List<ApiAnnotationsUtils.MethodPatternPair>> apiAnnotatedWith =
getApiAnnotatedWith(FrontendApi.class);
apiAnnotatedWith
.keySet()
.forEach(
method ->
expressionInterceptUrlRegistry
.antMatchers(
method,
apiAnnotatedWith.get(method).stream()
.map(ApiAnnotationsUtils.MethodPatternPair::getPattern)
.toArray(String[]::new))
.authenticated());
return expressionInterceptUrlRegistry
.antMatchers("/actuator/**")
.permitAll()
.anyRequest()
.permitAll()
.and();
}
@Log(Log.LoggingLevel.INFO)
public static Map<HttpMethod, List<MethodPatternPair>> getApiAnnotatedWith(Class<? extends Annotation> annotation) {
Map<HttpMethod, List<MethodPatternPair>> collect = getRequestMappingStream(annotation)
.flatMap(
request ->
Arrays.stream(request.method())
.map(m -> HttpMethod.resolve(m.toString()))
.flatMap(
m ->
Arrays.stream(request.path())
.map(path -> new MethodPatternPair(m, path))))
.collect(Collectors.groupingBy(MethodPatternPair::getMethod));
return collect;
}
@Log
public static Stream<RequestMapping> getRequestMappingStream(Class<? extends Annotation> annotation) {
return new Reflections("c.v.t.web.api.controller", new MethodAnnotationsScanner())
.getMethodsAnnotatedWith(annotation).stream()
.map(
method ->
Objects.requireNonNull(
AnnotationUtils.getAnnotation(method, RequestMapping.class)));
}
@Data
@AllArgsConstructor
public static class MethodPatternPair {
HttpMethod method;
String pattern;
} Not sure that will be able to create simple application now. |
I'm at a bit of a loss from the code you've attached what could be causing the problem, especially if Have you tried searching your codebase to make sure |
@stepanovdg the configuration processor shades JSON for internal purpose only. It's not meant to be used anywhere else, especially considering that an annotation processor is meant to be used at compile time only. You can do so by adding a dependency to |
@snicoll I'm not sure we've determined that @stepanovdg If you haven't got any |
It happens to me. I use another way in my codebase. But I tried spring-boot 2.3.x,it worked. By the way, will you fix this in |
@qyqcswill there's nothing to fix as far as I know. Please review the thread above. If you have imports on |
ok, great. I suggested my team upgrading the spring-boot version from spring-boot2.2.x to spring-boot2.4.x.I don't know anyone else who had import on |
Is there any way to wrap the lib spring-boot-configuration-processor-2.x.x.jar. This is because the code is using the org.springframework.boot.configurationprocessor.json.JSONException class |
@retamiro Please see Stephane's comment above. It sounds like you have some of your own code that's trying to use |
There are some microservices that have been misused, the goal is to minimize the impact. the problem occurs due to the "Jar Optimizations" implemented in spring 2.4x, so I asked if it has any way, but thanks for the feedback |
In our project we are using some annotations tools from configuration processor at runtime.
After recent spring version update (spring-boot-starter-parent 2.3.8 -> 2.5.2) almost everything was fine just at runtime we start getting:
In our
WebSecurityConfigurerAdapter.configure
code.After manually adding
spring-boot-configuration-processor-2.5.2.jar
intoBOOT-INF/lib/
folder of the build jar -> application is working fine (I was sure that previous class not found was due to wrap actual exception - but seems it was original problem).So right now we are not able to mark this jar not to be deleted from resulted artifact after this change
spring-boot/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractDependencyFilterMojo.java
Line 108 in b65cc4d
Is it possible to wrap registering of the
with some flag? by default it would exclude but if it is required for some corner cases like ours we can proceed using it?
The text was updated successfully, but these errors were encountered: