resources in a Spring Boot application are missing from jar file when using Spring Boot Maven Plugin

前端 未结 3 1440
醉话见心
醉话见心 2020-12-28 17:35

I am using Spring-Boot v1.3.0.M5 with Maven v3.3.3. I used to be able to run my Spring Boot (boot) application from the console with this command.

mvn clean pa

相关标签:
3条回答
  • 2020-12-28 18:00

    Try just this :

     <resources>
            <resource>
                <directory>src/main/resources/config</directory>
                <filtering>true</filtering>
                <includes>
                    <include>**/*.properties</include>
                </includes>
            </resource>  
    </resources>
    
    0 讨论(0)
  • 2020-12-28 18:20

    As described in the documentation mvn spring-boot:run adds src/main/resources in front of your classpath to support hot reload by default. You can turn this off easily

    <build>
      ...
      <plugins>
        ...
        <plugin>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-maven-plugin</artifactId>
          <version>1.2.7.RELEASE</version>
          <configuration>
            <addResources>false</addResources>
          </configuration>
        </plugin>
        ...
      </plugins>
      ...
    </build>
    
    0 讨论(0)
  • 2020-12-28 18:24

    Since Spring Boot 1.3, in order to have resources filtered as expected, we have to use new @@ format:

    some.key = @value@
    

    instead of classic:

    some.key = ${value}
    

    Relevant spring-boot issue: https://github.com/spring-projects/spring-boot/issues/980

    0 讨论(0)
提交回复
热议问题