我是实在搞不懂了,我用Intellj建一个Spring工程,选Spring Application模板,然后按照这本《Spring in action 4th Edition》第五章往上敲代码,只是简单写了一个Controller和几个配置文件,然后在Tomcat上运行,编译时没有错误,但是好像根本没有部署在Tomcat上啊?localhost:8080是空白页,请问是我Intellj设置的问题吗?还是配置文件的问题?我把所有XML都删了改成了书上的Java-based config,这样做不行吗?
附上代码https://github.com/zl2003cn/spittr
Tomcat运行时的日志是这样的
F:\apache-tomcat-8.0.21\bin\catalina.bat run
Using CATALINA_BASE: "C:\Users\Administrator.IntelliJIdea14\system\tomcat\Unnamed_spittr"
Using CATALINA_HOME: "F:\apache-tomcat-8.0.21"
Using CATALINA_TMPDIR: "F:\apache-tomcat-8.0.21\temp"
Using JRE_HOME: "C:\Program Files\Java\jdk1.8.0_31"
Using CLASSPATH: "F:\apache-tomcat-8.0.21\bin\bootstrap.jar;F:\apache-tomcat-8.0.21\bin\tomcat-juli.jar"
15-Apr-2015 16:03:58.145 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/8.0.21
15-Apr-2015 16:03:58.147 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Mar 23 2015 14:11:21 UTC
15-Apr-2015 16:03:58.147 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number: 8.0.21.0
15-Apr-2015 16:03:58.147 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Windows 8.1
15-Apr-2015 16:03:58.147 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 6.3
15-Apr-2015 16:03:58.148 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
15-Apr-2015 16:03:58.148 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: C:\Program Files\Java\jdk1.8.0_31\jre
15-Apr-2015 16:03:58.148 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.8.0_31-b13
15-Apr-2015 16:03:58.148 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
15-Apr-2015 16:03:58.151 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: C:\Users\Administrator.IntelliJIdea14\system\tomcat\Unnamed_spittr
15-Apr-2015 16:03:58.152 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: F:\apache-tomcat-8.0.21
15-Apr-2015 16:03:58.152 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote=
15-Apr-2015 16:03:58.153 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.port=1099
15-Apr-2015 16:03:58.153 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.ssl=false
15-Apr-2015 16:03:58.154 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.authenticate=false
15-Apr-2015 16:03:58.154 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.rmi.server.hostname=127.0.0.1
15-Apr-2015 16:03:58.154 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\Users\Administrator.IntelliJIdea14\system\tomcat\Unnamed_spittr\conf\logging.properties
15-Apr-2015 16:03:58.154 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
15-Apr-2015 16:03:58.154 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.endorsed.dirs=F:\apache-tomcat-8.0.21\endorsed
15-Apr-2015 16:03:58.155 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Users\Administrator.IntelliJIdea14\system\tomcat\Unnamed_spittr
15-Apr-2015 16:03:58.155 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=F:\apache-tomcat-8.0.21
15-Apr-2015 16:03:58.155 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=F:\apache-tomcat-8.0.21\temp
15-Apr-2015 16:03:58.156 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded APR based Apache Tomcat Native library 1.1.33 using APR version 1.5.1.
15-Apr-2015 16:03:58.156 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
15-Apr-2015 16:03:59.258 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized (OpenSSL 1.0.1m 19 Mar 2015)
15-Apr-2015 16:03:59.463 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-apr-8080"]
15-Apr-2015 16:03:59.477 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-apr-8009"]
15-Apr-2015 16:03:59.479 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 2222 ms
15-Apr-2015 16:03:59.548 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
15-Apr-2015 16:03:59.548 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.0.21
15-Apr-2015 16:03:59.582 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-apr-8080"]
15-Apr-2015 16:03:59.593 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-apr-8009"]
15-Apr-2015 16:03:59.594 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 114 ms
Connected to server
15-Apr-2015 16:04:09.597 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory F:\apache-tomcat-8.0.21\webapps\manager
15-Apr-2015 16:04:10.107 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory F:\apache-tomcat-8.0.21\webapps\manager has finished in 509 ms
1
monsoon 2015-04-15 16:53:38 +08:00
|
3
yushiro 2015-04-15 17:01:49 +08:00
没有仔细看你的错误信息, 不过我前几天也遇到spring的一些坑, 你可以参考一下。
我当时遇到的情况是, idea 14, 默认创建spring mvc项目, jdk是最新版的 java 8. tomcat也是最新版的, 但是运行项目就出错。 后来网上找了几篇文章, 至少让hello world项目跑起来了, 主要是以下几点 1. 用jre7 , 不要8, 2. tomcat的版本也降了一级 然后就都ok了。 |
5
cxshun 2015-04-15 21:11:52 +08:00
话说楼主你是一个web项目,去到连web.xml都没啦?这明显是有问题的啊。
你首先要让tomcat知道要加载spring,所以web.xml是必须的。而用ContextLoaderListener还是DispatcherServlet就看你自己喜欢了。 你找个例子,加上web.xml,加上相关的spring配置,其他代码看了应该是没问题的。 |
6
zl2003cn OP @chhx 你好!我是直接用Edit Configuration里的Tomcat Server->Local里指定本地的Tomcat服务器的,文档说Maven项目是不用设置Artifacts?还是我应该自己设置Artifact然后在Run\Debug Configuration的Deployment里手动添加?请不吝赐教
|
8
chhx 2015-04-15 22:22:16 +08:00
@zl2003cn http://my.oschina.net/zhanglubing/blog/94386 我是参考这里的,maven项目直接Run\Debug Configuration的command line 里 jetty:run ,tomcat应该也是类似。
|