C:\workspacej2ee\weishop>mvn jetty:run
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building weishop Maven Webapp 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> jetty-maven-plugin:9.2.2.v20140723:run (default-cli) > test-compile @ weishop >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ weishop ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ weishop ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ weishop ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\workspacej2ee\weishop\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ weishop ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] <<< jetty-maven-plugin:9.2.2.v20140723:run (default-cli) < test-compile @ weishop <<<
[INFO]
[INFO] --- jetty-maven-plugin:9.2.2.v20140723:run (default-cli) @ weishop ---
[INFO] Logging initialized @3515ms
[INFO] Configuring Jetty for project: weishop Maven Webapp
[INFO] webAppSourceDirectory not set. Trying src\main\webapp
[INFO] Reload Mechanic: automatic
[INFO] Classes = C:\workspacej2ee\weishop\target\classes
[INFO] Context path = /
[INFO] Tmp directory = C:\workspacej2ee\weishop\target\tmp
[INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml
[INFO] Web overrides = none
[INFO] web.xml file = file:/C:/workspacej2ee/weishop/src/main/webapp/WEB-INF/web.xml
[INFO] Webapp directory = C:\workspacej2ee\weishop\src\main\webapp
[INFO] jetty-9.2.2.v20140723
[INFO] No Spring WebApplicationInitializer types detected on classpath
[INFO] Initializing Spring root WebApplicationContext
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
[INFO] Initializing Spring FrameworkServlet 'mvc-dispatcher'
[INFO] Started o.e.j.m.p.JettyWebAppContext@79a1728c{/,file:/C:/workspacej2ee/weishop/src/main/webapp/,AVAILABLE}{file:/C:/workspacej2ee/weishop/src/main/webapp/}
[WARNING] !RequestLog
[INFO] Started ServerConnector@1a015bc0{HTTP/1.1}{0.0.0.0:8080}
[INFO] Started @7351ms
[INFO] Started Jetty Server
是可以的:(tomcat做server时,要加上项目名称):
http://localhost:8080/spring-mvc-study/hello/mvc 运行后报503错误,发现没有导入jstl的jar包,导入pom的坐标:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
完成:
大哥,你的问题解决了吗,我跟你一样的问题,我用的tomcat运行的,访问http://localhost:8080/ZLearnSpringMvc/hello/mvc就报错,ZLearnSpringMvc是我的项目名,求解答啊。。
这个问题我已经完全解决了,之间还遇到许多问题。
听我说可能的原因,首先这个 jetty的启动没什么问题,它已经启动了,然后由于是jetty做的web容器,所以你访问的应该是 http://localhost:8080/hello/mvc , 但是出现报错,看不出原因,因此我建议把jetty停掉,改为tomcat启动(用tomcat可以快速定位原因),此时先看它控制台有没有异常输出,然后tomcat 访问地址应该是: http://localhost:8080/你的项目名/hello/mvc ,再看 异常输出,之后就是对这些异常依个排除就行了。
等到tomcat可以正常访问,那换成jetty也可以访问了。
ps:顺便说一下我遇到的问题,
第一个问题是 java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet 。。。
解决方法:**工程名上右击 -> Properties -> Deployment Assembly,
Add -> Java Build Path Entries -> next -> 选择maven Dependencies**
第二个问题是 jstl not found
解决方法:在pom.xml里 加入:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
http://localhost:8080/spring-mvc-study/hello/mvc这个也不行
我不知道老师是怎么运行出来的,我用的myeclipse中的tomcat,应该输入http://localhost:8080/项目名/hello/mvc,才能正常显示
你的项目名叫weishop吧,你访问
http://localhost:8080/weishop/mvc才可以吧