我有一个Maven多模块项目,其中有一个父模块和三个子模块。该应用程序使用Spring Boot。在其中一个子模块中,我具有SpringBootApplication:
@SpringBootApplication
@EnableConfigurationProperties({AppProperties.class})
public class MainSpringBootApplication {
public static void main(String[] args) {
SpringApplication.run(MainSpringBootApplication.class, args);
}
}
应用程序属性在同一模块中:
@Data
@ConfigurationProperties(prefix = "asdf")
public class AppProperties {
...
}
在该模块的pom.xml中,有一个spring-boot-configuration-processor依赖项:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
现在的问题是,当我在父项目上运行mvn install时,未在此子模块中创建target / classes / META-INF / spring-configuration-metadata.json文件。当我修改该子模块的pom以直接继承自:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
并直接将mvn安装在子模块上,将生成target / classes / META-INF / spring-configuration-metadata.json文件。
你有什么提示吗?
我明确添加:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<annotationProcessorPaths>
<annotationProcessorPath>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<version>2.1.5.RELEASE</version>
</annotationProcessorPath>
</annotationProcessorPaths>
</configuration>
</plugin>
到plugins
包含@ConfigurationProperties
注释类的子模块的pom部分。现在target/classes/META-INF/spring-configuration-metadata.json
已生成。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句