Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/399.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.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
Java Maven在目标文件夹中解包war_Java_Maven_Tomcat - Fatal编程技术网

Java Maven在目标文件夹中解包war

Java Maven在目标文件夹中解包war,java,maven,tomcat,Java,Maven,Tomcat,我使用Maven创建JEE应用程序的WAR 这里是我的pom.xml <finalName>myproject</finalName> <sourceDirectory>${basedir}/src</sourceDirectory> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifac

我使用Maven创建JEE应用程序的WAR

这里是我的pom.xml

<finalName>myproject</finalName>
<sourceDirectory>${basedir}/src</sourceDirectory>
<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.5</version>
    <configuration>
        <warSourceDirectory>WebContent</warSourceDirectory>
        <failOnMissingWebXml>false</failOnMissingWebXml>
        <outputDirectory>/var/www/myproject/webapp</outputDirectory>
    </configuration>    
  </plugin>

  <plugin>
     <inherited>true</inherited>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.2</version>
    <configuration>
      <source>1.8</source>
      <target>1.8</target>
    </configuration>
  </plugin>
</plugins> 
myproject
${basedir}/src
org.apache.maven.plugins
maven战争插件
2.5
网络内容
假的
/var/www/myproject/webapp
真的
org.apache.maven.plugins
maven编译器插件
3.2
1.8
1.8
生成的WAR复制到pom.xml(/var/www/myproject/webapp)中定义的输出文件夹中,但我想在启动我的服务器(Tomcat)之前将其解压缩

我该怎么办

谢谢,
Lorenzo

如果你想打开战争的包装,你可以使用maven汇编插件。例如:

 <plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-dependency-plugin</artifactId>
     <version>2.10</version>
     <executions>
       <execution>
         <id>unpack</id>
         <phase>package</phase>
         <goals>
           <goal>unpack</goal>
         </goals>
         <configuration>
           <artifactItems>
             <artifactItem>
               <groupId>your group id</groupId>
               <artifactId>your artifact id</artifactId>
               <version> your version</version>
               <type>war</type>
               <overWrite>false</overWrite>
               <outputDirectory>${project.build.directory}/alternateLocation</outputDirectory>
               <destFileName>some name</destFileName>
               <includes>**/*.class,**/*.xml</includes>
               <excludes>**/*test.class</excludes>
             </artifactItem>
       </artifactItems>
       <includes>**/*.java</includes>
       <excludes>**/*.properties</excludes>
       <outputDirectory>your location</outputDirectory>
       <overWriteReleases>false</overWriteReleases>
       <overWriteSnapshots>true</overWriteSnapshots>
     </configuration>
   </execution>
 </executions>

org.apache.maven.plugins

有关更多详细信息。

如果您想解压战争,可以使用maven汇编插件。例如:

 <plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-dependency-plugin</artifactId>
     <version>2.10</version>
     <executions>
       <execution>
         <id>unpack</id>
         <phase>package</phase>
         <goals>
           <goal>unpack</goal>
         </goals>
         <configuration>
           <artifactItems>
             <artifactItem>
               <groupId>your group id</groupId>
               <artifactId>your artifact id</artifactId>
               <version> your version</version>
               <type>war</type>
               <overWrite>false</overWrite>
               <outputDirectory>${project.build.directory}/alternateLocation</outputDirectory>
               <destFileName>some name</destFileName>
               <includes>**/*.class,**/*.xml</includes>
               <excludes>**/*test.class</excludes>
             </artifactItem>
       </artifactItems>
       <includes>**/*.java</includes>
       <excludes>**/*.properties</excludes>
       <outputDirectory>your location</outputDirectory>
       <overWriteReleases>false</overWriteReleases>
       <overWriteSnapshots>true</overWriteSnapshots>
     </configuration>
   </execution>
 </executions>

org.apache.maven.plugins
有关更多详细信息。

您可以使用maven goal

您可以看到这个

您可以使用maven goal


你可以看到这个

你为什么要打开它?Tomcat可以处理.war文件,因为我正处于“艰难”的开发阶段,我想检查war是否包含所有需要的文件。您的
${basedir}/src
WebContent
保证了许多痛苦和头痛=/。为什么不使用Maven的约定?你有什么建议?最好的做法是什么?我是maven新手。您的源Java文件应该放在
src/main/Java
下,war源代码应该放在
src/main/webapp
下。看看你为什么要打开它?Tomcat可以处理.war文件,因为我正处于“艰难”的开发阶段,我想检查war是否包含所有需要的文件。您的
${basedir}/src
WebContent
保证了许多痛苦和头痛=/。为什么不使用Maven的约定?你有什么建议?最好的做法是什么?我是maven新手。您的源Java文件应该放在
src/main/Java
下,war源代码应该放在
src/main/webapp
下。另见