【发布时间】:2020-12-10 02:05:18
【问题描述】:
使用 maven 和 springboot。我想为每个环境(dev、cert)使用不同的文件配置(log4j2.xml、application.properties)。我在我的 pom.xml 文件上创建了两个配置文件,我在 src/main/resources 中有两个文件夹,每个文件配置(dev 和 cert)。我想根据我使用的配置文件包含这些文件。我在目录中有其他文件,所以我不想使用这种方式来创建两个路由和重复文件,我只想包含 src/main/resources 中的所有内容以及目录 dev 或 cert 中的文件。
我尝试使用:
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.1</version>
<configuration>
<packagingIncludes>src/main/resources/{resources.directory}</packagingIncludes>
</configuration>
</plugin>
但我得到了
[ERROR] 未能执行目标 org.springframework.boot:spring-boot-maven-plugin:1.4.3.RELEASE:repackage (默认)在项目 NProWebApp 上:目标的执行默认值 org.springframework.boot:spring-boot-maven-plugin:1.4.3.RELEASE:repackage 失败:找不到主类 -> [帮助 1]
编辑: 在 Maven 中添加配置文件:
<profiles>
<profile>
<id>dev</id>
<properties>
<packaging.type>jar</packaging.type>
</properties>
</profile>
<profile>
<id>cert</id>
<properties>
<packaging.type>war</packaging.type>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</profile>
</profiles>
【问题讨论】:
标签: spring-boot maven configuration log4j