我一直面临弹簧靴和maven的一些问题。
似乎<packaging>pom</packaging>
标签,当添加到pom.xml
时,不知何故使春天完全没有意识到父级applications.properties
配置文件。运行时,无论属性如何,spring仍会显示横幅和信息级别的日志记录。那为什么会这样?有没有办法将这些属性添加到我的父级,以便所有模块都可以在给定的配置下运行?这会变成反模式吗?
主要课程:
package com.example.app; //could also be inside the app-client module
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
application.properties:
spring.main.banner-mode=off
logging.level.root=info
(父)pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>
<modules>
<module>app-client</module>
</modules>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example.</groupId>
<artifactId>app</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>app</name>
<description>Demo app</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
完全同意Andy关于你的问题的评论我想指出,如果你想表示一个工件,使用packaging
类型pom
是合适的,因为某种模块容器是基础项目,你收集你的依赖信息(子)模块。
但是,您的案例中的@SpringBootApplication
向我们表明您希望使用工件来运行业务代码。另一方面,这导致packaging
类型,如jar
或war
。切换到其中一个,一切都应该运行正常。
有关更多信息,请参阅Maven reference for packaging。