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

百般思念 提交于 2019-11-30 05:10:33

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>

Try just this :

 <resources>
        <resource>
            <directory>src/main/resources/config</directory>
            <filtering>true</filtering>
            <includes>
                <include>**/*.properties</include>
            </includes>
        </resource>  
</resources>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!