关于idea如何集成svn请看前一篇,这里主要说说我导入eclipse纯web项目遇到的错误以及解决方法。
(一)导入项目
导入项目后会有很多报错,原因是各种依赖没有引入。下面讲讲如何具体解决
1)处理Project
如图显示1先new一个jdk环境,这个选择本地的就好
2则选择对应jdk版本的特性
3是选择编译后class文件输出的目录
2)处理Modules
Modeules是Project的子模块
修改src目录为Sources,resource为Resources
修改编译输出路径(有没有发现这和之前的project一样哎,废话因为Modules是Project的子模块,此处是但Modules的Project所以这里的设置和前面是一样的)
将eclipse的web项目的中lib文件里的jar引入到此项目中
add一个web
修改Path为你项目的web.xml的地址
修改Web Resource Directory将其指向导入的web项目的WebContent路径
3)处理Libraries中的信息
向Libraries中添加jar,这里和Modules中Dependencies中的区别是他是模块共享的
此处添加的Tomcat中包含servlet的api的jar
4)处理Artifacts
选择打war的模块
此处的Output directory随便搞个地方都无所谓的
(二)配置容器,我这边是Tomcat
首先添加一个Tomcat
Server基本不用做什么修改
Deployment这个地方需要注意下Application context默认是/,当项目启动时(以我本地为例),访问项目通过url:localhost:8080/index.html有没有觉得和正常的eclipse启动的不太一样?
没错,这边的端口号后面直接就是访问的页面的路径了,并没有带项目名。如果你想想eclipse那样的话只需修改Application context的值在/后写你的项目名即可。这时候访问地址就变成了localhost:8080/项目名/index.html
Logs配置的是选择输出的log
这么一个截图大概就能明白了
(三)启动项目
这里我故意修改下我的数据库连接信息,让其报错。来直观体验下。
先贴下在eclipse中启动报错的样子
看了后很直观,是哪边出错了。
现在贴下idea中一开始发现的错误的显示
- -!图帖不了了,就直接copy了
INFO - Closing Root WebApplicationContext: startup date [Tue Mar 28 20:32:24 CST 2017]; root of context hierarchy
INFO - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@33526b60: defining beans [dataSource_1,sqlSessionFactory_1,mapperScannerConfigurer_1,dailyScanSendSalesStatementServiceImpl,flowOrderDailyStatisticsServiceImpl,interfaceDataServiceImpl,smsInterfaceMonitorSchedulerServiceImpl,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0,dailyScanSendSalesStatementMapper,flowOrderDailyStatisticsMapper,interfaceDataMapper,smsInterfaceMonitorSchedulerMapper]; root of factory hierarchy
三月 28, 2017 8:32:25 下午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesJdbc
SEVERE: The web application [/sms] registered the JDBC driver [org.postgresql.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
[2017-03-28 08:32:25,622] Artifact sms-interface-monitor:war exploded: Error during artifact deployment. See server log for details.
三月 28, 2017 8:32:31 下午 org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:development omcatapache-tomcat-7.0.70webappsmanager
三月 28, 2017 8:32:31 下午 org.apache.catalina.startup.TldConfig execute
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
三月 28, 2017 8:32:31 下午 org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory D:development omcatapache-tomcat-7.0.70webappsmanager has finished in 104 ms
我发现了这么条信息Error during artifact deployment. See server log for details.
然后我翻到项目启动时打印的信息
D:development omcatapache-tomcat-7.0.70incatalina.bat run
[2017-03-28 08:40:34,220] Artifact sms-interface-monitor:war exploded: Server is not connected. Deploy is not available.
Using CATALINA_BASE: "C:UsersAdministrator.IntelliJIdea2016.3system omcatUnnamed_sms-interface-monitor_2"
Using CATALINA_HOME: "D:development omcatapache-tomcat-7.0.70"
Using CATALINA_TMPDIR: "D:development omcatapache-tomcat-7.0.70 emp"
Using JRE_HOME: "C:Program FilesJavajdk1.7.0_17"
Using CLASSPATH: "D:development omcatapache-tomcat-7.0.70inootstrap.jar;D:development omcatapache-tomcat-7.0.70in omcat-juli.jar"
我就去了C:UsersAdministrator.IntelliJIdea2016.3system omcatUnnamed_sms-interface-monitor_2
进入到logs目录下就会看到一堆日志文件也就是(二)中最后的截图的样子
打开localhost.2017-03-28.log其中一段就是
(到家了,终于又可以贴图了)
这个打印的消息就是eclipse中打印的消息。也就是错误信息,起初,我觉得idea好不人性,看个错误还要这么费事。然后又看看了,原来错误信息可以在这里看的
至此,在idea中搞个eclipse中的项目所遇到的问题基本都解决了。