gpt4 book ai didi

java - Maven:打包复制文件夹后复制粘贴WEB-INF到根目录

转载 作者:行者123 更新时间:2023-11-28 22:36:29 26 4
gpt4 key购买 nike

我有这样一个项目:

TestArt
-----------index.jsp
-----------pom.xml
-----------src
--------------main
------------------java/com/web/LoginServlet.java
------------------webapp/WEB-INF/classes/com/web/LoginServlet.class
-----------target
-----------------testproject-1.0-SNAPSHOT.war
-----------------testproject-1.0-SNAPSHOT.war.original
-----------------testproject-1.0-SNAPSHOT
----------------------------------META-INF
----------------------------------WEB-INF
---------------------------------------classes/com/web/LoginServlet.class
---------------------------------------lib (here are all the jars)

pom.xml像这样:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.util</groupId>
<artifactId>testproject</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>Test Project</name>
<url>https://test.com</url>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version>
</parent>

<dependencies>
...
</dependencies>

<properties>
<java.version>1.7</java.version>
<start-class>com.web.LoginServlet</start-class>
</properties>

<build>
<outputDirectory>${basedir}\src\main\webapp\WEB-INF\classes</outputDirectory>

<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals><goal>copy</goal></goals>
<configuration>

<artifactItems>

<artifactItem>
<groupId>com.github.jsimone</groupId>
<artifactId>webapp-runner</artifactId>
<version>8.0.30.2</version>
<destFileName>webapp-runner.jar</destFileName>
</artifactItem>

</artifactItems>

</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>

</plugin>

<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-compiler-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>

</plugins>

<defaultGoal>install</defaultGoal>
</build>
</project>

在我运行 mvn package 后,它会在 root/target 中创建 META-INFWEB-INF 文件夹文件夹,并将 .war 文件放在那里。

我希望 maven 在打包完成后将 WEB-INF 文件夹从 target 复制到根目录 (TestArt) 中。有什么办法可以实现吗?

最佳答案

我真的会建议花时间解决原来的问题,但如果你想:

使用 Maven Antrun 插件将文件夹从一个地方复制到另一个地方,如下所述:

https://stackoverflow.com/a/694175/927493

这里解释了 Ant 中复制命令的详细信息:

https://ant.apache.org/manual/Tasks/copy.html

关于java - Maven:打包复制文件夹后复制粘贴WEB-INF到根目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54725741/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com