Java springboot:maven包,具有特定的配置文件

Java springboot:maven包,具有特定的配置文件,java,spring,spring-boot,maven,deployment,Java,Spring,Spring Boot,Maven,Deployment,目标是拥有dev和prod环境。本地运行使用application-dev.yml,部署到服务器使用application-prod.yml 我有3个配置文件 application.yml spring: main: banner-mode: off spring: datasource: password: dev-user-pwd username: dev-user url: jdbc:mysql://localhost:3306/db

目标是拥有
dev
prod
环境。本地运行使用
application-dev.yml
,部署到服务器使用
application-prod.yml

我有3个配置文件

application.yml

spring:
  main:
    banner-mode: off
spring:
  datasource:
    password: dev-user-pwd
    username: dev-user
    url: jdbc:mysql://localhost:3306/db
    driver-class-name: com.mysql.cj.jdbc.Driver
spring:
  datasource:
    password: prod-user-pwd
    username: prod-user
    url: jdbc:mysql://localhost:3306/db
    driver-class-name: com.mysql.cj.jdbc.Driver
application-dev.yml

spring:
  main:
    banner-mode: off
spring:
  datasource:
    password: dev-user-pwd
    username: dev-user
    url: jdbc:mysql://localhost:3306/db
    driver-class-name: com.mysql.cj.jdbc.Driver
spring:
  datasource:
    password: prod-user-pwd
    username: prod-user
    url: jdbc:mysql://localhost:3306/db
    driver-class-name: com.mysql.cj.jdbc.Driver
application-prod.yml

spring:
  main:
    banner-mode: off
spring:
  datasource:
    password: dev-user-pwd
    username: dev-user
    url: jdbc:mysql://localhost:3306/db
    driver-class-name: com.mysql.cj.jdbc.Driver
spring:
  datasource:
    password: prod-user-pwd
    username: prod-user
    url: jdbc:mysql://localhost:3306/db
    driver-class-name: com.mysql.cj.jdbc.Driver
在服务器中,我安装了
maven
并尝试运行它

mvn clean package -Dspring.profiles.active=prod
这是我得到的错误日志

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 10.966 s <<< FAILURE! - in com.partplug.api.ApiApplicationTests
contextLoads  Time elapsed: 0.005 s  <<< ERROR!
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration': Unsatisfied dependency expressed through method 'setConfigurers' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.data.web.config.SpringDataWebConfiguration': Injection of autowired dependencies failed; nested exception is java.lang.NoClassDefFoundError: org/xmlbeam/config/XMLFactoriesConfig
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.data.web.config.SpringDataWebConfiguration': Injection of autowired dependencies failed; nested exception is java.lang.NoClassDefFoundError: org/xmlbeam/config/XMLFactoriesConfig
Caused by: java.lang.NoClassDefFoundError: org/xmlbeam/config/XMLFactoriesConfig
Caused by: java.lang.ClassNotFoundException: org.xmlbeam.config.XMLFactoriesConfig

测试运行:1,失败:0,错误:1,跳过:0,经过的时间:10.966秒请不要生成特定于环境的工件但请使用,不要生成特定于环境的工件但请使用