myeclipse新建项目需要配置的选项

来源:互联网 发布:java ftpclient api 编辑:程序博客网 时间:2024/06/05 22:49

今天很坑爹,配置spring出了很多莫名其妙的错,结果最后居然是一直在用tomcat7而没有用8,特地来总结一下


1.maven的web项目新建出来通常会有个The superclass "javax.servlet.http.HttpServlet" was not ...的错误,但是新建web project不会有这个问题。因为web project会自动加入javaEE 6.0这个lib,这里面有相关的包,这个可以通过导入servlet包解决,不是什么大问题。

<dependency><groupId>javax.servlet</groupId><artifactId>servlet-api</artifactId><version>2.5</version><scope>provided</scope></dependency>

2.web.xml文件的头部信息会有web module的版本选择,不要只在properties里面改完就算了

<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">  


3.maven web项目到底能不能直接部署到tomcat上?我猜不行,配置好相关的插件,最好用jetty。

<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>6.1.26</version>
<configuration>
<argLine>-XX:MaxPermSize=256m</argLine>
<systemProperties>
<systemProperty>
<name>log4j.configuration</name>
<value>log4j.properties</value>
</systemProperty>
</systemProperties>
<webApp>
<contextPath>/</contextPath>
</webApp>
<connectors>
<!-- work around file locking on windows -->
<connector implementation="org.eclipse.jetty.server.bio.SocketConnector">
<port>8080</port>
</connector>
</connectors>
</configuration>
</plugin>


4.不用maven的时候导入包一定要放到lib下。

0 0