SpringBoot Maven打包 xml 或 properties 文件丢失

avatar 2020年08月09日22:06:10 6 4068 views
博主分享免费Java教学视频,B站账号:Java刘哥

昨天帮一个朋友部署一个微服务架构的项目

其中一个父模块打包后,其子模块的配置文件(resources里的application.properties、bootstrap.properties)丢失了

即 mvn clean install 后在 target 的 classes 里只有 com 文件夹,没有配置文件

然后项目启动肯定是会报错的

 

最终找到原因

是父模块的 pom.xml 里配置了 resources,但是配置不完整,导致 java 文件夹里有 xml 之类的配置,但是 resources 里没有,只需要改成正确的即可

 

解决办法

父模块的 pom.xml 配置如下

<build>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <includes>
                <include>**/*.properties</include>
                <include>**/*.yml</include>
                <include>**/*.xml</include>
                <include>**/*.tld</include>
            </includes>
            <filtering>false</filtering>
        </resource>
        <resource>
            <directory>src/main/java</directory>
            <includes>
                <include>**/*.properties</include>
                <include>**/*.yml</include>
                <include>**/*.xml</include>
                <include>**/*.tld</include>
            </includes>
            <filtering>false</filtering>
        </resource>
    </resources>

    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
  • 微信
  • 交流学习,有偿服务
  • weinxin
  • 博客/Java交流群
  • 资源分享,问题解决,技术交流。群号:590480292
  • weinxin
avatar

发表评论

avatar 登录者:匿名
匿名评论,评论回复后会有邮件通知

  

已通过评论:0   待审核评论数:0