posts - 6, comments - 0, trackbacks - 0, articles - 0

2011年3月17日

%date:~0,10% %time:~0,8%
日期格式
2011-03-17 11:38:06



posted @ 2011-03-17 11:43 rainingcn 阅读(400) | 评论 (0)编辑 收藏

2011年3月16日

1. 使用Maven的maven-archetype-webapp 创建

mvn archetype:create -DgroupId=com.test -DartifactId=tutorial -DarchetypeArtifactId=maven-archetype-webapp
2.修改pom.xml。在build属性中增加jetty配置
<build>
    
<finalName>tutorial</finalName>
    
<plugins>
         
<plugin>
              
<groupId>org.mortbay.jetty</groupId>
              
<artifactId>maven-jetty-plugin</artifactId>
         
</plugin>
        
<!--
        
<plugin>               
            
<groupId>org.codehaus.mojo</groupId>               
            
<artifactId>tomcat-maven-plugin</artifactId>
        
</plugin>
        
-->
     
</plugins>
  
</build>
   2.1 可以输入 mvn jetty:run  启动jetty容器
3.增加struts2相关配置。具体的pom.xml文件
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation
="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  
<modelVersion>4.0.0</modelVersion>
  
<groupId>com.test</groupId>
  
<artifactId>tutorial</artifactId>
  
<packaging>war</packaging>
  
<version>1.0-SNAPSHOT</version>
  
<name>tutorial Maven Webapp</name>
  
<dependencies>
    
<dependency>
      
<groupId>junit</groupId>
      
<artifactId>junit</artifactId>
      
<version>4.8.1</version>
      
<scope>test</scope>
    
</dependency>
    
<dependency>
        
<groupId>org.apache.struts</groupId>
        
<artifactId>struts2-core</artifactId>
        
<version>2.2.1</version>
    
</dependency>

    
<dependency>
        
<groupId>log4j</groupId>
        
<artifactId>log4j</artifactId>
        
<version>1.2.14</version>
    
</dependency>
    
<dependency>
        
<groupId>javassist</groupId>
        
<artifactId>javassist</artifactId>
        
<version>3.8.0.GA</version>
    
</dependency>
  
</dependencies>
  
<build>
    
<finalName>tutorial</finalName>
    
<plugins>
         
<plugin>
              
<groupId>org.mortbay.jetty</groupId>
              
<artifactId>maven-jetty-plugin</artifactId>
         
</plugin>
        
<!--
        <plugin>               
            <groupId>org.codehaus.mojo</groupId>               
            <artifactId>tomcat-maven-plugin</artifactId>
        </plugin>
        
-->
     
</plugins>
  
</build>
</project>

4.导入到相关的IDE工具。如idea
mvn idea:idea
   4.1 idea中的目录结构

5.写个class 看下能否正常跳转。注意点:java类的源目录为
src
│  └─main
│      ├─java
public class Test {
    public String execute() {
        return "success";
    }
}
对应的struts.xml
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE struts PUBLIC
        "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
        "http://struts.apache.org/dtds/struts-2.0.dtd"
>

<struts>
    
<package name="default" extends="struts-default" namespace="/">
        
<action name="test" class="com.test.Test">
            
<result>index.jsp</result>
        
</action>
    
</package>
</struts>
6. url: http://localhost:8080/test

7.参考:
  

Building Web Applications with Maven 2

Create Struts 2 Web Application Using Maven To Manage Artifacts and To Build The Application
 

posted @ 2011-03-16 15:02 rainingcn 阅读(1559) | 评论 (0)编辑 收藏

2011年2月12日

idea中使用SourceSafe没有在eclipse使用简便。idea项目工程文件和SS上的工程文件要制定下。原先配过一次,很久不用又忘了。所以试着记下来。
具体步骤
1.配置SourceSafe

2.配置idea项目工程文件和SS上的工程文件


posted @ 2011-02-12 16:13 rainingcn 阅读(260) | 评论 (0)编辑 收藏

2010年12月20日

linux 自带的apache默认安装下,动态加载模块是不启动的。也就是意味着每一个httpd进程有自己独立的模块文件,分别独立。
这个在多并发的情况下会占用很大资源。
查看方式:
1.查看httpd进程数
ps -ef|grep httpd|wc -l
2.查看打开的文件模块数
 lsof |grep /usr/lib64/httpd/modules/mod_auth_basic.so|wc -l
解决方式:
重编译apache,
--enable-mods-shared=most


posted @ 2010-12-20 16:32 rainingcn 阅读(272) | 评论 (0)编辑 收藏

2010年12月16日

1.close_wait的产生原因,参考http://ahuaxuan.javaeye.com/blog/657511
图:

2.系统产生大量close_wait的原因是在大并发的情况下由于丢包或者系统压力导致来不及处理数据包的原因,导致socket没有得到很好的关闭。所以这个时候要调优下linux的系统参数
2.1调优参数,可以参看http://space.itpub.net/35489/viewspace-600807
2.2 参数说明,可以参看http://haka.sharera.com/blog/BlogTopic/32309.htm
2.3我目前结合系统修改后的配置:
 net.ipv4.tcp_keepalive_time=600
 net.ipv4.tcp_keepalive_probes
=5
 net.ipv4.tcp_keepalive_intvl
=15
3.可以lsof命令,查看大量close_wait所在端口的对应文件信息。
  参看http://www.ibm.com/developerworks/cn/aix/library/au-lsof.html

posted @ 2010-12-16 13:40 rainingcn 阅读(347) | 评论 (0)编辑 收藏

2010年12月14日

有时需要在服务器上每隔一段时间运行一段命令,以监控服务器性能。可以用crontab来做。
但是秒级的需要自己写shell脚本。
比如监控apache:
#!/bin/sh
echo 
"==========1.httpd==2.total connection==3.wait connection====4.jboss connection"
rp
=1
while rp=1
do
echo 
"================="
date 
-d today +"%T"
#show apache thread count
ps -ef|grep httpd|wc -l
#show total clients
netstat 
-ant|grep 10.108.10.2|wc -l
#show time_wait or ESTABLISHED clients
netstat 
-ant|grep ffff|wc -l
#show jboss connection
netstat 
-ant|grep 10.108.7.7|wc -l
sleep 
1
done

运行脚本前莫忘 chmod +x filename

posted @ 2010-12-14 16:10 rainingcn 阅读(248) | 评论 (0)编辑 收藏