Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring boot 如何在构建时将依赖项中的静态资源包含在spring boot胖jar中_Spring Boot_Maven - Fatal编程技术网

Spring boot 如何在构建时将依赖项中的静态资源包含在spring boot胖jar中

Spring boot 如何在构建时将依赖项中的静态资源包含在spring boot胖jar中,spring-boot,maven,Spring Boot,Maven,我有一个SpringBoot应用程序,它的UI是单独构建的,并作为依赖项添加到我的应用程序中。现在,我想解压依赖项,并在构建时将其添加到spring启动应用程序的resource文件夹中,以便它成为fat jar的一部分。有人可以指导我如何使用SpringBootMaven插件来实现这一点吗 注意:该项目正在使用maven进行构建 <build> <plugins> <plugin> <groupId>

我有一个SpringBoot应用程序,它的UI是单独构建的,并作为依赖项添加到我的应用程序中。现在,我想解压依赖项,并在构建时将其添加到spring启动应用程序的resource文件夹中,以便它成为fat jar的一部分。有人可以指导我如何使用SpringBootMaven插件来实现这一点吗

注意:该项目正在使用maven进行构建

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.2</version>
            <executions>
                <execution>
                    <id>nflow-explorer</id>
                    <phase>package</phase>
                    <goals>
                        <goal>unpack-dependencies</goal>
                    </goals>
                    <configuration>
                        <includeGroupIds>io.nflow</includeGroupIds>
                        <includeArtifactIds>nflow-explorer</includeArtifactIds>
                        <outputDirectory>
                            ${project.build.directory}/resources/main/static/explorer
                            <!-- or: ${project.basedir}/wherever/you/want/it -->
                        </outputDirectory>
                        <overWriteIfNewer>true</overWriteIfNewer>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>2.2.6.RELEASE</version>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>

        </plugin>
    </plugins>
</build>

org.apache.maven.plugins
maven依赖插件
2.2
nflow浏览器
包裹
解包依赖项
io.nflow
nflow浏览器
${project.build.directory}/resources/main/static/explorer
符合事实的
org.springframework.boot
springbootmaven插件
2.2.6.1发布
重新包装

您不必打开罐子的包装

只需使用Maven资源插件

您可以指定要包括的目录,如下所示:

<project>
 ...
 <build>
   ...
   <resources>
     <resource>
       <directory>[your folder here]</directory>
     </resource>
   </resources>
   ...
 </build>
 ...
</project>

...
...
[此处是您的文件夹]
...
...

这将如何成为脂肪罐的一部分???虽然目标文件夹似乎有静态资源,但fat jar不包含静态资源,我还是尝试了这个方法。添加了pom的build部分,但我看不出您正在pom.xml中使用资源插件,但您说您已经尝试过了。好的,我知道了。我在验证阶段复制了外部依赖项