Java 什么是 spring-boot-configuration-processor ?为什么人们将图书馆排除在外?为什么它在依赖树中不可见?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/53707080/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the spring-boot-configuration-processor ? Why do people exclude libraries from it? Why is it invisible in dependency tree?
提问by Menios
Introduction
介绍
So I noticed the following line in the gradle file of the jhipster project:
于是我在jhipster项目的gradle文件中注意到了下面这行:
annotationProcessor ("org.springframework.boot:spring-boot-configuration-processor") {
exclude group: 'com.vaadin.external.google', module: 'android-json'
}
We also used the same configuration in Maven for another project to solve the following problem: Maven transient dependency (library/jar vaadin json) is not being excluded
我们在另一个项目中也使用了Maven中相同的配置来解决以下问题:Maven 瞬态依赖(library/jar vaadin json)没有被排除
Questions
问题
And now I have the following questions:
现在我有以下问题:
- What does the spring-boot-configuration-processor dependency do?
- Why is it necessary to sometimes exclude dependencies from the processor?
- Why doesn't the processor necessarily appear in the mvn-dependency tree?
- Why are exclusions used with processor in situations where it's very difficult to exclude a dependency?
- spring-boot-configuration-processor 依赖有什么作用?
- 为什么有时需要从处理器中排除依赖项?
- 为什么处理器不一定出现在 mvn 依赖树中?
- 为什么在很难排除依赖项的情况下与处理器一起使用排除项?
采纳答案by Andy Wilkinson
spring-boot-configuration-processor
is an annotation processor that generates metadata about classes in your application that are annotated with @ConfigurationProperties
. This metadata is used by your IDE (Eclipse, IntelliJ, or NetBeans) to provide auto-completion and documentation for the properties when editing application.properties
and application.yaml
files. You can learn a bit more about it in the relevant sectionof Spring Boot's reference documentation.
spring-boot-configuration-processor
是一个注释处理器,用于生成有关应用程序中用@ConfigurationProperties
. IDE(Eclipse、IntelliJ 或 NetBeans)使用此元数据为编辑application.properties
和application.yaml
文件时的属性提供自动完成和文档。您可以在Spring Boot 参考文档的相关部分中了解更多相关信息。
Since Spring Boot 1.5.10, the exclusion is no longer necessary as com.vaadin.external.google:android-json
is no longer a dependency of spring-boot-configuration-processor
.
从 Spring Boot 1.5.10 开始,不再需要排除,因为com.vaadin.external.google:android-json
不再是spring-boot-configuration-processor
.
回答by Ryan Dawson
What does the spring-boot-configuration-processor dependency do?
spring-boot-configuration-processor 依赖有什么作用?
It scans the libraries in the build and sees what properties they useso as to inform the IDE
Why is it necessary to sometimes exclude dependencies from the processor?
为什么有时需要从处理器中排除依赖项?
Maven libraries can clash sometimes - the one you reference was excluded by JHipster because it led to errors when on the classpath together with another library in JHipster's dependencies
Maven 库有时会发生冲突 - 您引用的库被 JHipster 排除,因为它在类路径上与 JHipster 依赖项中的另一个库一起导致错误
Why doesn't the processor necessarily appear in the mvn dependency:tree?
为什么处理器不一定出现在 mvn dependency:tree 中?
It does for me on the jhipster-sample-app
. Presumably you're referring to the comment on the linked issuestating that the android-json
library isn't in the tree. I've asked there about that.
它在jhipster-sample-app
. 大概您指的是对链接问题的评论,指出该android-json
库不在树中。我已经问过那里了。
Why are exclusions used with processor in situations where it's very difficult to exclude a dependency?
为什么在很难排除依赖项的情况下与处理器一起使用排除项?
This is a dependency clashissue like any other really, it just happens that the processor is bringing in the key dependency (or rather was, as @Andy Wilkinsonpoints out com.vaadin.external.google:android-json
is no longer used by the processor)
这是一个依赖冲突问题,就像任何其他真正的问题一样,它只是碰巧处理器引入了关键依赖(或者更确切地说,正如@Andy Wilkinson指出的那样com.vaadin.external.google:android-json
,处理器不再使用)