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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.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
Maven Dynamic Web项目:My war以其名称的版本部署。如何改变它?_Maven_War - Fatal编程技术网

Maven Dynamic Web项目:My war以其名称的版本部署。如何改变它?

Maven Dynamic Web项目:My war以其名称的版本部署。如何改变它?,maven,war,Maven,War,出于某种原因,我的war部署为name-version.war 在您将此标记为重复甚至否决我之前,我尝试了所有在线找到的解决方案,但都无效。到目前为止,我已经尝试: POM中的最终名称标签 maven war插件及其属性warName 编辑org.eclipse.wst.common.component并将部署名称更改为我的名称 因此,eclipse在“在服务器上运行”之后打开的url不起作用: 应该是: 实际有效的url: 这快把我逼疯了 我做错了什么 这是我的POM: <pro

出于某种原因,我的war部署为name-version.war

在您将此标记为重复甚至否决我之前,我尝试了所有在线找到的解决方案,但都无效。到目前为止,我已经尝试:

  • POM中的最终名称标签
  • maven war插件及其属性warName
  • 编辑org.eclipse.wst.common.component并将部署名称更改为我的名称
因此,eclipse在“在服务器上运行”之后打开的url不起作用:

应该是:

实际有效的url:

这快把我逼疯了

我做错了什么

这是我的POM:

<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>
    <packaging>war</packaging>
    <name>kest</name>
    <build>
    <finalName>kest</finalName>
        <resources>
            <resource>
                <directory>${basedir}/src/main/java</directory>
                <excludes>
                    <exclude>**/*.java</exclude>
                </excludes>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <warSourceDirectory>${basedir}/WebContent</warSourceDirectory>
                    <failOnMissingWebXml>false</failOnMissingWebXml>

                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <repositories>

        <repository>
            <id>prime-repo</id>
            <name>PrimeFaces Maven Repository</name>
            <url>http://repository.primefaces.org</url>
            <layout>default</layout>
        </repository>
    </repositories>

    <dependencies>
        <!-- Primefaces Version 6 -->
        <dependency>
            <groupId>org.primefaces</groupId>
            <artifactId>primefaces</artifactId>
            <version>6.0</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>5.0.9.Final</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>7.0</version>
        </dependency>

    </dependencies>
    <groupId>my.package.kest</groupId>
    <artifactId>kest</artifactId>
    <version>1.0</version>
</project>

4.0.0
战争
凯斯特
凯斯特
${basedir}/src/main/java
**/*.爪哇
maven战争插件
2.6
${basedir}/WebContent
错误的
maven编译器插件
3
1.8
1.8
优质回购
PrimeFacesMaven存储库
http://repository.primefaces.org
违约
org.primefaces
素面
6
org.hibernate
冬眠核心
5.0.9.1最终版本
假如
爪哇
JavaEEAPI
7
我的包
凯斯特
1
My Web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
  <display-name>kest</display-name>
  <welcome-file-list>
    <welcome-file>index.xhtml</welcome-file>
  </welcome-file-list>
  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
  </servlet-mapping>
</web-app>

凯斯特
index.xhtml
Facesservlet
javax.faces.webapp.FacesServlet
1.
Facesservlet
*.xhtml

我可能看起来很傻,我不知道这是否有效。 在最终名称声明之前,我只是将组id、工件id和版本移到了顶部

请尝试以下方法:

<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>
    <packaging>war</packaging>
   <groupId>my.package.kest</groupId>
    <artifactId>kest</artifactId>
    <version>1.0</version>
    <name>kest</name>
    <build>
    <finalName>kest</finalName>
        <resources>
            <resource>
                <directory>${basedir}/src/main/java</directory>
                <excludes>
                    <exclude>**/*.java</exclude>
                </excludes>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <warSourceDirectory>${basedir}/WebContent</warSourceDirectory>
                    <failOnMissingWebXml>false</failOnMissingWebXml>

                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <repositories>

        <repository>
            <id>prime-repo</id>
            <name>PrimeFaces Maven Repository</name>
            <url>http://repository.primefaces.org</url>
            <layout>default</layout>
        </repository>
    </repositories>

    <dependencies>
        <!-- Primefaces Version 6 -->
        <dependency>
            <groupId>org.primefaces</groupId>
            <artifactId>primefaces</artifactId>
            <version>6.0</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>5.0.9.Final</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>7.0</version>
        </dependency>

    </dependencies>

</project>

4.0.0
战争
我的包
凯斯特
1
凯斯特
凯斯特
${basedir}/src/main/java
**/*.爪哇
maven战争插件
2.6
${basedir}/WebContent
错误的
maven编译器插件
3
1.8
1.8
优质回购
PrimeFacesMaven存储库
http://repository.primefaces.org
违约
org.primefaces
素面
6
org.hibernate
冬眠核心
5.0.9.1最终版本
假如
爪哇
JavaEEAPI
7
如果最终名称不起作用,请使用下面的名称并尝试使用与上面相同的xml。 在maven war插件的内部版本中,请更改

<warName> ${artifactId} </warName>
${artifactId}
例:

kest
替换:

        <build>
       ..........                       
        <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.6</version>
            <configuration>
                <warSourceDirectory>${basedir}/WebContent</warSourceDirectory>
                <failOnMissingWebXml>false</failOnMissingWebXml>
                <warName>kest</warName>
            </configuration>
        </plugin>
     .............
   <build>

..........                       
maven战争插件
2.6
${basedir}/WebContent
错误的
凯斯特
.............

我将-clean添加到eclipse.ini中,并清理和重建了所有内容,现在它可以工作了(即使没有或


也许这对其他人会有帮助…

将版本放在文件名中是个好主意。这不是你的问题。你的服务器从文件名中获取其
上下文,这就是问题所在。你可能缺少一个web.xml?我已经有了,在我的第一篇文章中,我列出了我已经尝试过的解决方案:'(你能提到你在Eclipse中使用的是哪台服务器吗?我正在使用WildFly 10。我已经编辑了我的答案。我不确定它是否能工作。请尝试。谢谢你的帮助,但它没有改变。不过,我只是回答了我自己的问题。
        <build>
       ..........                       
        <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.6</version>
            <configuration>
                <warSourceDirectory>${basedir}/WebContent</warSourceDirectory>
                <failOnMissingWebXml>false</failOnMissingWebXml>
                <warName>kest</warName>
            </configuration>
        </plugin>
     .............
   <build>