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
使用Maven创建war并在jboss上部署_Maven_Servlets_Jboss - Fatal编程技术网

使用Maven创建war并在jboss上部署

使用Maven创建war并在jboss上部署,maven,servlets,jboss,Maven,Servlets,Jboss,我创建了一个具有基本原型的maven项目。在/webapp/web-INF下创建了web.xml web.xml如下所示 <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee

我创建了一个具有基本原型的maven项目。在/webapp/web-INF下创建了web.xml

web.xml如下所示

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
          http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
          version="3.0">
          <welcome-file-list>  
   <welcome-file>home.html</welcome-file>  

  </welcome-file-list>  
</web-app>

home.html
xml如下所示

<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.tvashtra</groupId>
  <artifactId>HelloWorld</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>

  <dependencies>
  <!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->

  <!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>4.0.0</version>
    <scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.servlet.jsp/jsp-api -->


  </dependencies>
  <build>
  <plugins>
  <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.1</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
  </plugins>
  </build>
</project>

4.0.0
com.tvashtra

现在,在做了所有这些之后,我部署了这场战争,但似乎什么都不起作用

*

* *

* 以上两个链接都显示消息“无法访问该站点”

上下文根是HelloWorld

在google/youtubing上,我遇到了很多他们使用Tomcat服务器作为插件的例子,但我不想这样

提前谢谢


正如下面的评论所建议的,我创建了jboss-web.xml并保存在web-INF下 我正在使用JBOSS 7 EAP,下面是JBOSS-web.xml的内容

<?xml version="1.0" encoding="UTF-8"?>
<jboss-web xmlns="http://www.jboss.com/xml/ns/javaee"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="
      http://www.jboss.com/xml/ns/javaee
      http://www.jboss.org/j2ee/schema/jboss-web_5_1.xsd">
   <context-root>/HelloWorld</context-root>
</jboss-web>

/地狱世界

但是仍然无法达到目标

似乎存在多个jboss实例在同一台机器上运行的问题

在没有jboss-web.xml的情况下遵循完全相同的过程

<?xml version="1.0" encoding="UTF-8"?>
<jboss-web xmlns="http://www.jboss.com/xml/ns/javaee"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="
      http://www.jboss.com/xml/ns/javaee
      http://www.jboss.org/j2ee/schema/jboss-web_5_1.xsd">
   <context-root>/HelloWorld</context-root>
</jboss-web>
还从pom中删除了servlet依赖项,并在下面添加了一个

<dependency>
    <groupId>javax</groupId>
    <artifactId>javaee-web-api</artifactId>
    <version>8.0</version>
    <scope>provided</scope>
</dependency>

爪哇
javaeewebapi
8
假如

它就像一个符咒

您的war文件名是什么?必须使用jboss-web.xml来设置上下文根。您的war中是否存在此文件?@ehsavoie war文件以上下文根命名,即HelloWorld.war,项目中未使用jboss-web.xml,但后来我进行了建议的修改。请参考编辑后的问题帖。@ehsavoie如果您能看看jboss-web.xml,我将不胜感激,因为我怀疑它的版本是否合适。