1

我正在尝试在 Eclipse 中创建一个简单的 Maven 应用程序。我正在使用弹簧。我在tomcat server.xml的以下行中添加了以下行

    <Context docBase="E:\Java\eclipse\Workspace\j2eeexample\target\j2eeexample-0.0.1-SNAPSHOT.war" path="/test" reloadable="true"/>

docBase 的路径是正确的。我的 maven srs/main/webapp 中也有以下 jsp 文件:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Insert title here</title>
</head>
<body>
<h1> Hi kousha</h1>
</body>
 </html>

当我作为 Maven install 运行程序时,我得到的唯一警告是:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource

接着:

[INFO] BUILD SUCCESS

但是当我运行服务器并输入 URL (localhost:8020/test) 时,我得到一个 HTTP 状态 404 错误。

如果我错过了什么,知道吗?

顺便说一句,我尝试了“mvn --version”命令并且它可以工作(所以我猜maven安装没有问题)。

这是我在 Maven 安装模式下运行程序时的整个控制台:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Marven_test 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ j2eeexample ---
[debug] execute contextualize
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ j2eeexample ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ j2eeexample ---
[debug] execute contextualize
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ j2eeexample ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.10:test (default-test) @ j2eeexample ---
[INFO] Surefire report directory: E:\Java\eclipse\Workspace\j2eeexample\target\surefire-reports

-------------------------------------------------------
T E S T S
-------------------------------------------------------

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

[INFO] 
[INFO] --- maven-war-plugin:2.1.1:war (default-war) @ j2eeexample ---
[INFO] Packaging webapp
[INFO] Assembling webapp [j2eeexample] in [E:\Java\eclipse\Workspace\j2eeexample\target\j2eeexample-0.0.1-SNAPSHOT]
[INFO] Processing war project
[INFO] Copying webapp resources [E:\Java\eclipse\Workspace\j2eeexample\src\main\webapp]
[INFO] Webapp assembled in [15 msecs]
[INFO] Building war: E:\Java\eclipse\Workspace\j2eeexample\target\j2eeexample-0.0.1-SNAPSHOT.war
[WARNING] Warning: selected war files include a WEB-INF/web.xml which will be ignored 
(webxml attribute is missing from war task, or ignoreWebxml attribute is specified as 'true')
[INFO] 
[INFO] --- maven-install-plugin:2.3.1:install (default-install) @ j2eeexample ---
[INFO] Installing E:\Java\eclipse\Workspace\j2eeexample\target\j2eeexample-0.0.1-SNAPSHOT.war to C:\Users\kousha\.m2\repository\Mave\j2eeexample\0.0.1-SNAPSHOT\j2eeexample-0.0.1-SNAPSHOT.war
[INFO] Installing E:\Java\eclipse\Workspace\j2eeexample\pom.xml to C:\Users\kousha\.m2\repository\Mave\j2eeexample\0.0.1-SNAPSHOT\j2eeexample-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.157s
[INFO] Finished at: Thu Mar 07 14:42:36 PST 2013
[INFO] Final Memory: 9M/243M
[INFO] ------------------------------------------------------------------------
4

0 回答 0