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

Projects
3 participants
@YannCebron

YannCebron commented Jun 5, 2018

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

This comment has been minimized.

Contributor

ryanjbaxter commented Jun 5, 2018

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

This comment has been minimized.

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

This comment has been minimized.

Contributor

snicoll commented Jun 6, 2018

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

@ryanjbaxter

This comment has been minimized.

Contributor

ryanjbaxter commented Jun 6, 2018

@snicoll thanks. We will try this for Finchley.

@ryanjbaxter

This comment has been minimized.

Contributor

ryanjbaxter commented Jun 6, 2018

@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

This comment has been minimized.

Contributor

snicoll commented Jun 6, 2018

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

@ryanjbaxter

This comment has been minimized.

Contributor

ryanjbaxter commented Jun 7, 2018

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

@snicoll

This comment has been minimized.

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