首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >仅用maven安装的url中的应用程序名称无法访问的应用程序

仅用maven安装的url中的应用程序名称无法访问的应用程序
EN

Stack Overflow用户
提问于 2017-08-29 11:47:03
回答 1查看 92关注 0票数 0

问题:

我正在从git位置https://github.com/javaee-samples/javaee7-samples/tree/master/jsf/bean-validation中试用JSF验证应用程序示例。我对pom.xml文件和settings.xml进行了必要的自定义更改,以指向自己的本地.m2/repository。在Wildfly 10上部署应用程序并将其作为http://localhost:8180/bean-validation/faces通过url访问之后,我无法访问欢迎页面。

但是当我将url重写为http://localhost:8180/bean-validation-1.0-SNAPSHOT/faces时,我可以访问欢迎页面。

在服务器->部署文件夹中,maven (通过命令行中的mvn命令)将bean验证bean-validation-1.0-SNAPSHOT.war部署为.war

我需要在我的pom.xml文件中更改什么才能访问只有网址中的web应用程序名称的页面?

我定制的pom.xml文件如下所示:

代码语言:javascript
复制
<?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>
<!--     <parent>
        <groupId>org.javaee7.jsf</groupId>
        <artifactId>jsf-samples</artifactId>
        <version>1.0-SNAPSHOT</version>
        <relativePath>../pom.xml</relativePath>
    </parent> -->

    <groupId>org.javaee7.jsf</groupId>
    <artifactId>bean-validation</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>

    <dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-api</artifactId>
        <version>2.1.11</version>
    </dependency>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-web-api</artifactId>
        <version>6.0</version>
    </dependency>
<!--    <dependency>
        <groupId>javax.enterprise</groupId>
        <artifactId>javaee-api</artifactId>
        <version>6.0</version>
    </dependency> -->
    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-impl</artifactId>
        <version>2.1.11</version>
    </dependency>
</dependencies>
        <build>
        <plugins>
            <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.3</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1.1</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>
EN

回答 1

Stack Overflow用户

发布于 2017-08-29 13:46:27

要从构建的target目录中立即部署,可以通过在pom.xml文件中添加一个finalName来修复名称:

代码语言:javascript
复制
 <build>
      <finalName>bean-validation</finalName>
      ...
 </build>

但是,如果将来有一个应用程序部署过程,可以从本地存储库或远程存储库部署应用程序,那么您可能必须以依赖供应商的方式配置应用程序web上下文。

如果要在EAR文件中部署web应用程序,则还可以通过添加

代码语言:javascript
复制
  <context-root>bean-validation</context-root>

它在application.xml文件中的定义。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45938333

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档