mvn archetype:generate -DgroupId=com.bestpay.support.gd -DartifactId=JBatchReward -DarchetypeArtifactId=maven-archetype-j2ee-simple
看maven-definitive-guide到第五章了,發現maven可以創建不少類型的demo,只要輸入:
mvn archetype:create就可以 不過,創建的同時需要archetypeArtifactId這個參數來識別,不過不太清楚有什么類型,只知道默認不填是maven-archetype-quickstart ,web是maven-archetype-webapp 發現有更簡單的方法,只要輸入mvn archetype:generate 就會將所有可用的類型顯示,并且讓你自己選,輸出如下: 1: internal -> appfuse-basic-jsf (AppFuse archetype for creating a web application with Hibernate, Spring and JSF) 2: internal -> appfuse-basic-spring (AppFuse archetype for creating a web application with Hibernate, Spring and Spring MVC) 3: internal -> appfuse-basic-struts (AppFuse archetype for creating a web application with Hibernate, Spring and Struts 2) 4: internal -> appfuse-basic-tapestry (AppFuse archetype for creating a web application with Hibernate, Spring and Tapestry 4) 5: internal -> appfuse-core (AppFuse archetype for creating a jar application with Hibernate and Spring and XFire) 6: internal -> appfuse-modular-jsf (AppFuse archetype for creating a modular application with Hibernate, Spring and JSF) 7: internal -> appfuse-modular-spring (AppFuse archetype for creating a modular application with Hibernate, Spring and Spring MVC) 8: internal -> appfuse-modular-struts (AppFuse archetype for creating a modular application with Hibernate, Spring and Struts 2) 9: internal -> appfuse-modular-tapestry (AppFuse archetype for creating a modular application with Hibernate, Spring and Tapestry 4) 10: internal -> maven-archetype-j2ee-simple (A simple J2EE Java application) 11: internal -> maven-archetype-marmalade-mojo (A Maven plugin development project using marmalade) 12: internal -> maven-archetype-mojo (A Maven Java plugin development project) 13: internal -> maven-archetype-portlet (A simple portlet application) 14: internal -> maven-archetype-profiles () 15: internal -> maven-archetype-quickstart () 16: internal -> maven-archetype-site-simple (A simple site generation project) 17: internal -> maven-archetype-site (A more complex site project) 18: internal -> maven-archetype-webapp (A simple Java web application) 19: internal -> struts2-archetype-starter (A starter Struts 2 application with Sitemesh, DWR, and Spring) 20: internal -> struts2-archetype-blank (A minimal Struts 2 application) 21: internal -> struts2-archetype-portlet (A minimal Struts 2 application that can be deployed as a portlet) 22: internal -> struts2-archetype-dbportlet (A starter Struts 2 portlet that demonstrates a simple CRUD interface with db backing) 23: internal -> struts2-archetype-plugin (A Struts 2 plugin) 24: internal -> shale-archetype-blank (A blank Shale web application with JSF) 25: internal -> maven-adf-archetype (Archetype to ease the burden of creating a new application based with ADF) 26: internal -> data-app (A new Databinder application with sources and resources.) 27: internal -> jini-service-archetype (Archetype for Jini service project creation) 28: internal -> softeu-archetype-seam (JSF+Facelets+Seam Archetype) 29: internal -> softeu-archetype-seam-simple (JSF+Facelets+Seam (no persistence) Archetype) 30: internal -> softeu-archetype-jsf (JSF+Facelets Archetype) 31: internal -> jpa-maven-archetype (JPA application) 32: internal -> spring-osgi-bundle-archetype (Spring-OSGi archetype) 33: internal -> confluence-plugin-archetype (Atlassian Confluence plugin archetype) 34: internal -> maven-archetype-har (Hibernate Archive) 35: internal -> maven-archetype-sar (JBoss Service Archive) 36: internal -> wicket-archetype-quickstart (A simple Apache Wicket project)
也可以使用防止SQL注入PreparedStatement方法
摘要: 在windows系統中,windows提供了計劃任務這一功能,在控制面板 -> 性能與維護 -> 任務計劃, 它的功能就是安排自動運行的任務。 通過'添加任務計劃'的一步步引導,則可建立一個定時執行的任務。在linux系統中你可能已經發現了為什么系統常常會自動的進行一些任務?這些任務到底是誰在支配他們工作的?在linux系統如... 閱讀全文
我在上傳些代碼的時候,有時候會遇到“git did not exit cleanly (exit code 128)”錯誤。通常都是網絡原因。 找了網上解決的方法: 1、鼠標右鍵 -> TortoiseGit -> Settings -> Network 2、SSH client was pointing to C:\Program Files\TortoiseGit\bin\TortoisePlink.exe 3、Changed path to C:\Program Files (x86)\Git\bin\ssh.exe 一、javah命令(C Header and Stub File Generator) 二、jps命令(Java Virtual Machine Process Status Tool) 四、jstat命令(Java Virtual Machine Statistics Monitoring Tool) 六、jinfo命令(Java Configuration Info) 七、jconsole命令(Java Monitoring and Management Console) 八、jvisualvm命令(Java Virtual Machine Monitoring, Troubleshooting, and Profiling Tool) 九、jhat命令(Java Heap Analyse Tool) 十一、Jstatd命令(Java Statistics Monitoring Daemon)jstack用于打印出給定的java進程ID或core file或遠程調試服務的Java堆棧信息,如果是在64位機器上,需要指定選項"-J-d64",Windows的jstack使用方式只支持以下的這種方式: 在摘了另一篇博客的三種場景: 實例一:Waiting to lock 和 Blocked "RMI TCP Connection(267865)-172.16.5.25" daemon prio=10 tid=0x00007fd508371000 nid=0x55ae waiting for monitor entry [0x00007fd4f8684000] java.lang.Thread.State: BLOCKED (on object monitor) at org.apache.log4j.Category.callAppenders(Category.java:201) - waiting to lock <0x00000000acf4d0c0> (a org.apache.log4j.Logger) at org.apache.log4j.Category.forcedLog(Category.java:388) at org.apache.log4j.Category.log(Category.java:853) at org.apache.commons.logging.impl.Log4JLogger.warn(Log4JLogger.java:234) at com.tuan.core.common.lang.cache.remote.SpyMemcachedClient.get(SpyMemcachedClient.java:110) 說明: 實例二:Waiting on condition 和 TIMED_WAITING "RMI TCP Connection(idle)" daemon prio=10 tid=0x00007fd50834e800 nid=0x56b2 waiting on condition [0x00007fd4f1a59000] java.lang.Thread.State: TIMED_WAITING (parking) at sun.misc.Unsafe.park(Native Method) - parking to wait for <0x00000000acd84de8> (a java.util.concurrent.SynchronousQueue$TransferStack) at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:198) at java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(SynchronousQueue.java:424) at java.util.concurrent.SynchronousQueue$TransferStack.transfer(SynchronousQueue.java:323) at java.util.concurrent.SynchronousQueue.poll(SynchronousQueue.java:874) at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:945) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) at java.lang.Thread.run(Thread.java:662)
說明: 1)“TIMED_WAITING (parking)”中的 timed_waiting 指等待狀態,但這里指定了時間,到達指定的時間后自動退出等待狀態;parking指線程處于掛起中。 "RMI RenewClean-[172.16.5.19:28475]" daemon prio=10 tid=0x0000000041428800 nid=0xb09 in Object.wait() [0x00007f34f4bd0000] java.lang.Thread.State: TIMED_WAITING (on object monitor) at java.lang.Object.wait(Native Method) - waiting on <0x00000000aa672478> (a java.lang.ref.ReferenceQueue$Lock) at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:118) - locked <0x00000000aa672478> (a java.lang.ref.ReferenceQueue$Lock) at sun.rmi.transport.DGCClient$EndpointEntry$RenewCleanThread.run(DGCClient.java:516) at java.lang.Thread.run(Thread.java:662) 說明: 1)“TIMED_WAITING (on object monitor)”,對于本例而言,是因為本線程調用了 java.lang.Object.wait(long timeout) 而進入等待狀態。 2)“Wait Set”中等待的線程狀態就是“ in Object.wait() ”。當線程獲得了 Monitor,進入了臨界區之后,如果發現線程繼續運行的條件沒有滿足,它則調用對象(一般就是被 synchronized 的對象)的 wait() 方法,放棄了 Monitor,進入 “Wait Set”隊列。只有當別的線程在該對象上調用了 notify() 或者 notifyAll() ,“ Wait Set”隊列中線程才得到機會去競爭,但是只有一個線程獲得對象的 Monitor,恢復到運行態。 參考: 命令匯總:http://blog.csdn.net/fenglibing/article/details/6411940 1. 如何加大tomcat連接數 在tomcat配置文件server.xml中的<Connector ... />配置中,和連接數相關的參數有: maxThreads : tomcat起動的最大線程數,即同時處理的任務個數,默認值為200。 minProcessors:最小空閑連接線程數,用于提高系統處理性能,默認值為10 。 maxProcessors:最大連接線程數,即:并發處理的最大請求數,默認值為75 。 acceptCount: 當tomcat起動的線程數達到最大時,接受排隊的請求個數,默認值為100。 minSpareThreads :Tomcat初始化時創建的線程數。 maxSpareThreads :一旦創建的線程超過這個值,Tomcat就會關閉不再需要的socket線程。 enableLookups:是否反查域名,取值為:true或false。 缺省值為false,表示使用客戶端主機名的DNS解析功能,被ServletRequest.getRemoteHost方法調用。 connectionTimeout:網絡連接超時,單位:毫秒。設置為0表示永不超時,這樣設置有隱患的。通常可設置為30000毫秒。
web server允許的最大連接數還受制于操作系統的內核參數設置,通常Windows是2000個左右,Linux是1000個左右。 Unix中如何設置這些參數,請參閱Unix常用監控和管理命令 tomcat5中的配置示例: <Connector port="8090" maxHttpHeaderSize="8169" maxThreads="1000" minSpareThreads="75" maxSpareThreads="300" enableLookups="false" redirectPort="8649" acceptCount="100" connectionTimeout="50000" disableUploadTimeout="true" URIEncoding="GBK"/> <Connector className="org.apache.coyote.tomcat4.CoyoteConnector" port="8080" minProcessors="10" maxProcessors="1024" enableLookups="false" redirectPort="8443" acceptCount="1024" debug="0" connectionTimeout="30000" /> 在{tomcat_home}/conf/web.xml中,把listings參數設置成false即可,如下: <servlet> ... <init-param> <param-name>listings</param-name> <param-value>false</param-value> </init-param> ... </servlet>
tomcat默認可以使用的內存為128MB,在較大型的應用項目中,這點內存是不夠的,需要調大。 JAVA_OPTS='-Xms【初始化內存大小】 -Xmx【可以使用的最大內存】' 需要把這個兩個參數值調大。 例如: JAVA_OPTS='-Xms256m -Xmx512m' 表示初始化內存為256MB,可以使用的最大內存為512MB 。
export JAVA_HOME='/home/ftpuser/xjSheetHome/java/jdk1.5.0_22/' JAVA_OPTS="-Xms1500m -Xmx1500m -Xss1024K -XX:PermSize=128m -XX:MaxPermSize=256m -Dfile.encoding=GBK" 參數說明: -Xms 是指設定程序啟動時占用內存大小。一般來講,大點,程序會啟動的 快一點,但是也可能會導致機器暫時間變慢。 -Xmx 是指設定程序運行期間最大可占用的內存大小。如果程序運行需要占 用更多的內存,超出了這個設置值,就會拋出OutOfMemory 異常。 -Xss 是指設定每個線程的堆棧大小。這個就要依據你的程序,看一個線程 大約需要占用多少內存,可能會有多少線程同時運行等。 -XX:PermSize設置非堆內存初始值,默認是物理內存的1/64 。 -XX:MaxPermSize設置最大非堆內存的大小,默認是物理內存的1/4。
<Context path="/Sheet" defaultSessionTimeOut="3600" docBase="/home/user/Sheet" >
摘要: 首先先介紹一款知名的網站壓力測試工具:webbench.
Webbench能測試處在相同硬件上,不同服務的性能以及不同硬件上同一個服務的運行狀況。webbench的標準測試可以向我們展示服務器的兩項內容:每分鐘相應請求數和每秒鐘傳輸數據量。webbench不但能具有便準靜態頁面的測試能力,還能對動態頁面(ASP,PHP,JAVA,CGI)進 行測試的能力。還有就是他支持對含有SSL的安全網站例如... 閱讀全文
1.內存設置(VM參數調優) 二、TOMCAT內存監控 1.設置tomcat的perm size: 2.開啟監控 在命令行輸入jconsole,在彈出窗口中建立本地端口監控,如下圖:
使用安裝版Tomcat 6.0 ,打開tomcat界面選擇java這一項,在java options:
使用jconsole 127.0.0.1:8088可以連接成功,也能看到jvm運行情況, |