<<上篇 | 首页 | 下篇>>

Maven2 一个完整的pom.xml

Maven2是一个很好的build工具,它简化了项目管理,用它的插件可生成各种报表,自动化测试等等。但是把已有的项目转移到Maven2上其实是一件痛苦的事情,但关键在于要理解 pom.xml文件。我的经验是,一旦你的应用包依赖搞定了的话,就用mvn -o site来离线进行maven2工作

安装第三方包:
mvn install:install-file -Dfile=E:/workdir/dg_new/主站/源代码/m2m/lib/mail-1.3.jar -DartifactId=javamail -Dversion=1.3.1 -Dpackaging=jar -DgroupId=javamail

遵循Maven2的规范源代码目录。

创建新项目:

mvn archetype:create -DgroupId=cas.security -DartifactId=securityApp -DarchetypeArtifactId=maven-archetype-webapp

cd securityApp

创建war文件:

mvn package

创建Eclipse项目文件:

mvn eclipse:eclipse

部署 webapps internal (so we can point the Context.xml file in tomcat to the source dir):

mvn war:inplace

mvn test

mvn compile

(The above should copy the jar files we need.)

Add M2_REPO to workspace:
mvn -Declipse.workspace=D:\workspaces\clientQ

eclipse:add-maven-repo

Maven文档:http://maven.apache.org/guides/getting-started/index.html

下面是一个完整的pom.xml:

阅读全文……

标签 :

What does the exception "java.net.SocketException: Connection reset by peer" mean? How can this be avoided?

It usually happens when the connection was reset by the peer -- that is, when the client unexpectedly closed the socket. This happens when the user clicks "stop", or "reload", or "back", or enters a new URL, or closes his Internet connection, while a resource is still being downloaded (before your server gets to close its socket). This is normal behavior and you shouldn't worry about it.

The server is reporting "connection reset by peer" in the middle of a request. That means one of the following things:

  • The browser started a request and the user pressed STOP.
  • The browser started an request in one frame and JavaScript on another frame told it to go somewhere else (which has the same effect as a user pressing STOP).
  • You have a meta refresh reload someplace that is firing so fast that the previous request hasn't had a chance to complete yet. The five second periodicity makes me pretty suspicious of this.
  • You have some network component in between (a router or proxy) that is misbehaving.
  • You have some completely separate connection attempts going on that are disobeying the HTTP protocol (such as doing a telnet connection to port 8080 and then disconnecting).
标签 : ,

java URLConnection and timeout and non-blocking io

自从JDK1.5以后java.net.URLConnection加入了setConnectTimeout(int timeout),但是也有办法在JDK1.5以前获得这个功能。
Adding Socket Timeout to java.net.URLConnection
HTTPClient Version 0.3-3
The Jakarta Commons HttpClient
另外,可以通过以下两个语句来设置相应的超时:
System.setProperty("sun.net.client.defaultConnectTimeout", 连接超时毫秒数);
System.setProperty("sun.net.client.defaultReadTimeout", 读数据超时毫秒数);
参见:http://java.sun.com/j2se/1.4.2/docs/guide/net/properties.html
google:set Timeout on URLConnection

标签 :