使用Maven开战并部署在jboss上

问题描述 投票:0回答:1

我创建了一个具有基本原型的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>

pom.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>

home.html存在于webapp文件夹中,但在WEB-INF目录之外。与此类似,通过扩展如下所示的HttpServlet类,创建了一个servlet。

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/Login")
public class ServletOne extends HttpServlet
{
    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException
    {
        try {
        PrintWriter out = response.getWriter();

        out.println("<html>");
        out.println("<head>");
        out.println("<title>Mukesh Khanna</title>");
        out.println("</head>");
        out.println("<body>");
        out.println("<h2>My name is Ashish Parab</h2>");
        out.println("</body>");
        out.println("</html>");
        }
        catch(IOException e)
        {
            e.printStackTrace();
        }

    }

}

我确保jboss http端口在9080端口上正常工作jboss http port working

现在完成所有这些之后,我部署了战争,但是似乎什么都没用。

*

http://localhost:9080/HelloWorld

**

http://localhost:9080/HelloWorld/Login*以上两个链接均显示消息“无法访问该站点”

上下文根是HelloWorldWeb Project Setting

在谷歌搜索/ 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>

但是仍然无法击中目标http://localhost:9080/HelloWorld

maven servlets jboss
1个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.