Skip to content
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

Spring Boot support: use annotation processor org.springframework.boot.autoconfigureprocessor.AutoConfigureAnnotationProcessor in builds #377

Closed
YannCebron opened this issue Jun 5, 2018 · 8 comments

Comments

@YannCebron
Copy link

It seems Spring Cloud is currently not using above AP which generates additional metadata in META-INF/spring-autoconfigure-metadata.properties, storing a number of annotations/attributes for auto-configuration classes.

This information can be used both by Spring Boot to avoid classloading on startup by reading this metadata instead of loading/inspecting annotations of all autoconfiguration classes.
Furthermore, this metadata is already used by tools (e.g. IntelliJ IDEA's Spring support) to achieve a similar goal.

Given the large total # of autoconfiguration classes across all Spring Cloud -* projects, this seems a worthwhile step to improve performance.

PS: I'm unsure whether this is the correct subproject, but obviously it should be applied across all Spring Cloud projects providing autoconfiguration classes.

@ryanjbaxter
Copy link
Contributor

Reading through
https://docs.spring.io/spring-boot/docs/current/reference/html/configuration-metadata.html#configuration-metadata-annotation-processor

Sounds like we just need to add

<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-configuration-processor</artifactId>
	<optional>true</optional>
</dependency>

to our POMs

@ryanjbaxter ryanjbaxter added this to To do in Finchley.RELEASE via automation Jun 5, 2018
@ryanjbaxter ryanjbaxter added this to the 2.0.0.RELEASE milestone Jun 5, 2018
@snicoll
Copy link
Contributor

snicoll commented Jun 6, 2018

@ryanjbaxter that's the annotation processor generating configuration keys metadata. What @YannCebron means is the annotation processor that generates metadata on auto-configuration so that we don't have to load/parse the class at runtime.

The correct dependency is

<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-autoconfigure-processor</artifactId>
	<optional>true</optional>
</dependency>

It should be added in any project that has a spring.factories with registered auto-configurations.

@snicoll
Copy link
Contributor

snicoll commented Jun 6, 2018

I've added a note to the ref guide as well.

@ryanjbaxter
Copy link
Contributor

@snicoll thanks. We will try this for Finchley.

@ryanjbaxter
Copy link
Contributor

@snicoll when I added this to spring-cloud-netflix it looks like it generated a file called spring-autoconfigure-metadata.properties. The documentation said it should be a json file, is this OK?

@snicoll
Copy link
Contributor

snicoll commented Jun 6, 2018

Thanks for the feedback. I made a typo and will fix the doc. Thank you!

@ryanjbaxter
Copy link
Contributor

@snicoll would anything go wrong if this dependency was present and there was no spring.factories in that project?

@snicoll
Copy link
Contributor

snicoll commented Jun 7, 2018

No, it will generate metadata for the @Configuration classes that it finds. We have plans to use that information in the future. However, I'd advise to explicitly add the dependency where that makes sense (vs. adding that dependency in a parent or something if that's what you have in mind).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

No branches or pull requests

3 participants