- 浏览: 56447 次
- 性别:
- 来自: ShangHai
最新评论
-
tuspark:
关于java字符的内容,还有很多,例如这篇文章所讲:《Java ...
java 的字符编码 -
mbsky:
xiandaoyan 写道文章很好,楼主可不可以把spring ...
Spring Batch Getting Started -
zhizhuoweichen008:
怎么下载地址都是打不开的,能不能给个完整的源代码
Spring batch sample 之 text to DB -
skydazzle:
我想问一下,如果我是想用spring batch 从数据库里读 ...
Spring batch sample 之 text to DB -
shayu1989:
sorry 本来想点顶的 不小心点错了 。。抱歉
java 转码
来自:
http://struts2.group.iteye.com/group/blog/387088
关键字: maven2 archetype ssh
最近用spring2.5.6+hibernate3.2+struts2.0.14做项目,用这些框架做项目最鬼麻烦的就是搭建工程的基本原型,为了在以后不用在这么麻烦,于是就有了创建一个自己的ssh的archetype的念头,说干就干,开始动手。
1.创建一个maven项目(在eclipse 中通过m2eclipse创建或者用mvn archetype:genetate命令创建)。
2.添加spring,hibernate,struts2的依赖包,我的pom.xml如下:
Xml代码
1. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3. <modelVersion>4.0.0</modelVersion>
4. <groupId>org.eagle</groupId>
5. <artifactId>ssh-base</artifactId>
6. <packaging>war</packaging>
7. <version>0.0.1-SNAPSHOT</version>
8. <build>
9. <plugins>
10. <plugin>
11. <groupId>org.apache.maven.plugins</groupId>
12. <artifactId>maven-compiler-plugin</artifactId>
13. <version>2.0.2</version>
14. <configuration>
15. <source>1.6</source>
16. <target>1.6</target>
17. </configuration>
18. </plugin>
19. <plugin>
20. <groupId>org.mortbay.jetty</groupId>
21. <artifactId>maven-jetty-plugin</artifactId>
22. <version>6.1.14</version>
23. </plugin>
24. </plugins>
25. </build>
26.
27. <dependencies>
28. <dependency>
29. <groupId>javax.servlet</groupId>
30. <artifactId>servlet-api</artifactId>
31. <version>2.5</version>
32. <type>jar</type>
33. <scope>provided</scope>
34. </dependency>
35. <dependency>
36. <groupId>org.springframework</groupId>
37. <artifactId>spring</artifactId>
38. <version>2.5.6</version>
39. <type>jar</type>
40. <scope>compile</scope>
41. </dependency>
42. <dependency>
43. <groupId>org.aspectj</groupId>
44. <artifactId>aspectjrt</artifactId>
45. <version>1.6.2</version>
46. <type>jar</type>
47. <scope>compile</scope>
48. </dependency>
49. <dependency>
50. <groupId>org.aspectj</groupId>
51. <artifactId>aspectjweaver</artifactId>
52. <version>1.6.2</version>
53. <type>jar</type>
54. <scope>compile</scope>
55. </dependency>
56. <dependency>
57. <groupId>org.apache.struts</groupId>
58. <artifactId>struts2-core</artifactId>
59. <version>2.0.14</version>
60. <type>jar</type>
61. <scope>compile</scope>
62. </dependency>
63. <dependency>
64. <groupId>org.apache.struts</groupId>
65. <artifactId>struts2-spring-plugin</artifactId>
66. <version>2.0.14</version>
67. <type>jar</type>
68. <scope>compile</scope>
69. <exclusions>
70. <exclusion>
71. <artifactId>spring-beans</artifactId>
72. <groupId>org.springframework</groupId>
73. </exclusion>
74. <exclusion>
75. <artifactId>spring-core</artifactId>
76. <groupId>org.springframework</groupId>
77. </exclusion>
78. <exclusion>
79. <artifactId>spring-context</artifactId>
80. <groupId>org.springframework</groupId>
81. </exclusion>
82. <exclusion>
83. <artifactId>spring-web</artifactId>
84. <groupId>org.springframework</groupId>
85. </exclusion>
86. </exclusions>
87. </dependency>
88. <dependency>
89. <groupId>org.hibernate</groupId>
90. <artifactId>hibernate</artifactId>
91. <version>3.2.6.ga</version>
92. <type>jar</type>
93. <scope>compile</scope>
94. </dependency>
95. <dependency>
96. <groupId>mysql</groupId>
97. <artifactId>mysql-connector-java</artifactId>
98. <version>5.1.6</version>
99. <type>jar</type>
100. <scope>runtime</scope>
101. </dependency>
102. <dependency>
103. <groupId>c3p0</groupId>
104. <artifactId>c3p0</artifactId>
105. <version>0.9.1.2</version>
106. <type>jar</type>
107. <scope>compile</scope>
108. </dependency>
109. <dependency>
110. <groupId>log4j</groupId>
111. <artifactId>log4j</artifactId>
112. <version>1.2.14</version>
113. <type>jar</type>
114. <scope>compile</scope>
115. </dependency>
116. <dependency>
117. <groupId>cglib</groupId>
118. <artifactId>cglib-nodep</artifactId>
119. <version>2.1_3</version>
120. <type>jar</type>
121. <scope>compile</scope>
122. </dependency>
123. </dependencies>
124. </project>
<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>org.eagle</groupId>
<artifactId>ssh-base</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.14</version>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.5.6</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.6.2</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.6.2</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.0.14</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-spring-plugin</artifactId>
<version>2.0.14</version>
<type>jar</type>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>spring-beans</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>spring-core</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>spring-context</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>spring-web</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
<version>3.2.6.ga</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
<type>jar</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>c3p0</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.1.2</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<version>2.1_3</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
3.添加基本的配置文件
src/main/resources/applicationContext.xml
Xml代码
1. <?xml version="1.0" encoding="UTF-8"?>
2. <beans xmlns="http://www.springframework.org/schema/beans"
3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
4. xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
5. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
6. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
7. http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
8. http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
9. <context:property-placeholder location="WEB-INF/config/jdbc.properties" />
10.
11. <!-- 定义数据源Bean,使用C3P0数据源实现 -->
12. <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
13. destroy-method="close">
14. <!-- 指定连接数据库的驱动 -->
15. <property name="driverClass" value="${jdbc.driverClassName}" />
16. <!-- 指定连接数据库的URL -->
17. <property name="jdbcUrl" value="${jdbc.url}" />
18. <!-- 指定连接数据库的用户名 -->
19. <property name="user" value="${jdbc.username}" />
20. <!-- 指定连接数据库的密码 -->
21. <property name="password" value="${jdbc.password}" />
22. <!-- 指定连接数据库连接池的最大连接数 -->
23. <property name="maxPoolSize" value="20" />
24. <!-- 指定连接数据库连接池的最小连接数 -->
25. <property name="minPoolSize" value="1" />
26. <!-- 指定连接数据库连接池的初始化连接数 -->
27. <property name="initialPoolSize" value="1" />
28. <!-- 指定连接数据库连接池的连接的最大空闲时间 -->
29. <property name="maxIdleTime" value="20" />
30. </bean>
31.
32. <bean id="sessionFactory"
33. class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
34. <property name="dataSource" ref="dataSource" />
35. <property name="mappingDirectoryLocations">
36. <list>
37. <value>classpath:org/eagle/orm</value>
38. </list>
39. </property>
40. <property name="hibernateProperties">
41. <props>
42. <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect
43. </prop>
44. <prop key="show_sql">true</prop>
45. <prop key="hibernate.hbm2ddl.auto">update</prop>
46. <prop key="hibernate.jdbc.batch_size">20</prop>
47. </props>
48. </property>
49. </bean>
50.
51. <!-- 配置事务管理器 -->
52. <bean id="transactionManager"
53. class="org.springframework.orm.hibernate3.HibernateTransactionManager">
54. <property name="sessionFactory" ref="sessionFactory" />
55. </bean>
56.
57. <!-- 配置事务的传播性 -->
58. <tx:advice id="txAdvice" transaction-manager="transactionManager">
59. <tx:attributes>
60. <tx:method name="add*" propagation="REQUIRED" />
61. <tx:method name="del*" propagation="REQUIRED" />
62. <tx:method name="modify*" propagation="REQUIRED" />
63. <tx:method name="*" read-only="true" />
64. </tx:attributes>
65. </tx:advice>
66.
67. <!-- 配置哪些类哪些方法使用事务 -->
68. <aop:config>
69. <!-- 配置切入点(定义哪些方法要进行事务处理) -->
70. <aop:pointcut id="allManager"
71. expression="execution(* org.eagle.services..*.*(..))" />
72. <!-- 定义advice -->
73. <aop:advisor advice-ref="txAdvice" pointcut-ref="allManager" />
74. </aop:config>
75.
76. </beans>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
<context:property-placeholder location="WEB-INF/config/jdbc.properties" />
<!-- 定义数据源Bean,使用C3P0数据源实现 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<!-- 指定连接数据库的驱动 -->
<property name="driverClass" value="${jdbc.driverClassName}" />
<!-- 指定连接数据库的URL -->
<property name="jdbcUrl" value="${jdbc.url}" />
<!-- 指定连接数据库的用户名 -->
<property name="user" value="${jdbc.username}" />
<!-- 指定连接数据库的密码 -->
<property name="password" value="${jdbc.password}" />
<!-- 指定连接数据库连接池的最大连接数 -->
<property name="maxPoolSize" value="20" />
<!-- 指定连接数据库连接池的最小连接数 -->
<property name="minPoolSize" value="1" />
<!-- 指定连接数据库连接池的初始化连接数 -->
<property name="initialPoolSize" value="1" />
<!-- 指定连接数据库连接池的连接的最大空闲时间 -->
<property name="maxIdleTime" value="20" />
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="mappingDirectoryLocations">
<list>
<value>classpath:org/eagle/orm</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect
</prop>
<prop key="show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="hibernate.jdbc.batch_size">20</prop>
</props>
</property>
</bean>
<!-- 配置事务管理器 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- 配置事务的传播性 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED" />
<tx:method name="del*" propagation="REQUIRED" />
<tx:method name="modify*" propagation="REQUIRED" />
<tx:method name="*" read-only="true" />
</tx:attributes>
</tx:advice>
<!-- 配置哪些类哪些方法使用事务 -->
<aop:config>
<!-- 配置切入点(定义哪些方法要进行事务处理) -->
<aop:pointcut id="allManager"
expression="execution(* org.eagle.services..*.*(..))" />
<!-- 定义advice -->
<aop:advisor advice-ref="txAdvice" pointcut-ref="allManager" />
</aop:config>
</beans>
src/main/resources/struts.xml
Xml代码
1. <?xml version="1.0" encoding="UTF-8"?>
2.
3. <!DOCTYPE struts PUBLIC
4. "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
5. "http://struts.apache.org/dtds/struts-2.0.dtd">
6.
7. <struts>
8.
9. </struts>
<?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>
</struts>
src/main/webapp/WEB-INF/config/jdbc.properties
Java代码
1. jdbc.driverClassName=com.mysql.jdbc.Driver
2. jdbc.url=jdbc:mysql://localhost:3306/shs2
3. jdbc.username=root
4. jdbc.password=ubuntu
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/shs2
jdbc.username=root
jdbc.password=ubuntu
src/main/webapp/WEB-INF/config/log4j.properties
Java代码
1. log4j.rootLogger=INFO, stdout, logfile
2.
3. log4j.appender.stdout=org.apache.log4j.ConsoleAppender
4. log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
5. log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n
6.
7. log4j.appender.logfile=org.apache.log4j.RollingFileAppender
8. log4j.appender.logfile.File=${webapp.root}/WEB-INF/logs/pcdiy.log
9. log4j.appender.logfile.MaxFileSize=512KB
10. # Keep three backup files.
11. log4j.appender.logfile.MaxBackupIndex=3
12. # Pattern to output: date priority [category] - message
13. log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
14. log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n
log4j.rootLogger=INFO, stdout, logfile
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n
log4j.appender.logfile=org.apache.log4j.RollingFileAppender
log4j.appender.logfile.File=${webapp.root}/WEB-INF/logs/pcdiy.log
log4j.appender.logfile.MaxFileSize=512KB
# Keep three backup files.
log4j.appender.logfile.MaxBackupIndex=3
# Pattern to output: date priority [category] - message
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n
4.web.xml
Xml代码
1. <?xml version="1.0" encoding="UTF-8"?>
2. <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3. xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
4. xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
5. id="WebApp_ID" version="2.5">
6.
7. <context-param>
8. <param-name>contextConfigLocation</param-name>
9. <param-value>classpath:applicationContext.xml</param-value>
10. </context-param>
11.
12. <context-param>
13. <param-name>log4jConfigLocation</param-name>
14. <param-value>/WEB-INF/config/log4j.properties</param-value>
15. </context-param>
16. <filter>
17. <filter-name>struts2</filter-name>
18. <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
19. </filter>
20. <filter-mapping>
21. <filter-name>struts2</filter-name>
22. <url-pattern>/*</url-pattern>
23. </filter-mapping>
24.
25. <listener>
26. <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
27. </listener>
28. <listener>
29. <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
30. </listener>
31. </web-app>
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/config/log4j.properties</param-value>
</context-param>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
</web-app>
5.基本上可以,现在来生成archetype的目录结构(假设工程在/home/lingshangwen/project/ssh-base)
进入到工程的根目录ssh-base下
$cd ~/project/ssh-base
$mvn archetype:create-from-project
运行完该命令后,将会有如下的目录~/project/ssh-base/target/generated-sources/archetype
6.创建archetype
$cd ~/project/ssh-base/target/generated-sources/archetype
$mvn install
到现在为止,我想要的ssh的archetype创建出来了,如何通过该archetype创建项目呢,很简单,看看
$cd ~/project
$mvn archetype:generate
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO] task-segment: [archetype:generate] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] Preparing archetype:generate
[INFO] No goals needed for project - skipping
[INFO] Setting property: classpath.resource.loader.class => 'org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader'.
[INFO] Setting property: velocimacro.messages.on => 'false'.
[INFO] Setting property: resource.loader => 'classpath'.
[INFO] Setting property: resource.manager.logwhenfound => 'false'.
[INFO] [archetype:generate]
[INFO] Generating project in Interactive mode
[INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0)
Choose archetype:
1: local -> ssh (null)
2: local -> ssh-base-archetype (ssh-base-archetype)
3: internal -> appfuse-basic-jsf (AppFuse archetype for creating a web application with Hibernate, Spring and JSF)
4: internal -> appfuse-basic-spring (AppFuse archetype for creating a web application with Hibernate, Spring and Spring MVC)
5: internal -> appfuse-basic-struts (AppFuse archetype for creating a web application with Hibernate, Spring and Struts 2)
6: internal -> appfuse-basic-tapestry (AppFuse archetype for creating a web application with Hibernate, Spring and Tapestry 4)
7: internal -> appfuse-core (AppFuse archetype for creating a jar application with Hibernate and Spring and XFire)
8: internal -> appfuse-modular-jsf (AppFuse archetype for creating a modular application with Hibernate, Spring and JSF)
9: internal -> appfuse-modular-spring (AppFuse archetype for creating a modular application with Hibernate, Spring and Spring MVC)
10: internal -> appfuse-modular-struts (AppFuse archetype for creating a modular application with Hibernate, Spring and Struts 2)
11: internal -> appfuse-modular-tapestry (AppFuse archetype for creating a modular application with Hibernate, Spring and Tapestry 4)
12: internal -> maven-archetype-j2ee-simple (A simple J2EE Java application)
13: internal -> maven-archetype-marmalade-mojo (A Maven plugin development project using marmalade)
14: internal -> maven-archetype-mojo (A Maven Java plugin development project)
15: internal -> maven-archetype-portlet (A simple portlet application)
16: internal -> maven-archetype-profiles ()
17: internal -> maven-archetype-quickstart ()
18: internal -> maven-archetype-site-simple (A simple site generation project)
19: internal -> maven-archetype-site (A more complex site project)
20: internal -> maven-archetype-webapp (A simple Java web application)
21: internal -> jini-service-archetype (Archetype for Jini service project creation)
22: internal -> softeu-archetype-seam (JSF+Facelets+Seam Archetype)
23: internal -> softeu-archetype-seam-simple (JSF+Facelets+Seam (no persistence) Archetype)
24: internal -> softeu-archetype-jsf (JSF+Facelets Archetype)
25: internal -> jpa-maven-archetype (JPA application)
26: internal -> spring-osgi-bundle-archetype (Spring-OSGi archetype)
27: internal -> confluence-plugin-archetype (Atlassian Confluence plugin archetype)
28: internal -> jira-plugin-archetype (Atlassian JIRA plugin archetype)
29: internal -> maven-archetype-har (Hibernate Archive)
30: internal -> maven-archetype-sar (JBoss Service Archive)
31: internal -> wicket-archetype-quickstart (A simple Apache Wicket project)
32: internal -> scala-archetype-simple (A simple scala project)
33: internal -> lift-archetype-blank (A blank/empty liftweb project)
34: internal -> lift-archetype-basic (The basic (liftweb) project)
35: internal -> cocoon-22-archetype-block-plain ([http://cocoon.apache.org/2.2/maven-plugins/])
36: internal -> cocoon-22-archetype-block ([http://cocoon.apache.org/2.2/maven-plugins/])
37: internal -> cocoon-22-archetype-webapp ([http://cocoon.apache.org/2.2/maven-plugins/])
38: internal -> myfaces-archetype-helloworld (A simple archetype using MyFaces)
39: internal -> myfaces-archetype-helloworld-facelets (A simple archetype using MyFaces and facelets)
40: internal -> myfaces-archetype-trinidad (A simple archetype using Myfaces and Trinidad)
41: internal -> myfaces-archetype-jsfcomponents (A simple archetype for create custom JSF components using MyFaces)
42: internal -> gmaven-archetype-basic (Groovy basic archetype)
43: internal -> gmaven-archetype-mojo (Groovy mojo archetype)
Choose a number: (1/2/3/4/5/6/7/8/9/10/11/12/13/14/15/16/17/18/19/20/21/22/23/24/25/26/27/28/29/30/31/32/33/34/35/36/37/38/39/40/41/42/43) 17: :
ssh-base的archetype为2,故选择2
~~有个这个archetype以后创建ssh项目就快多了
http://struts2.group.iteye.com/group/blog/387088
关键字: maven2 archetype ssh
最近用spring2.5.6+hibernate3.2+struts2.0.14做项目,用这些框架做项目最鬼麻烦的就是搭建工程的基本原型,为了在以后不用在这么麻烦,于是就有了创建一个自己的ssh的archetype的念头,说干就干,开始动手。
1.创建一个maven项目(在eclipse 中通过m2eclipse创建或者用mvn archetype:genetate命令创建)。
2.添加spring,hibernate,struts2的依赖包,我的pom.xml如下:
Xml代码
1. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3. <modelVersion>4.0.0</modelVersion>
4. <groupId>org.eagle</groupId>
5. <artifactId>ssh-base</artifactId>
6. <packaging>war</packaging>
7. <version>0.0.1-SNAPSHOT</version>
8. <build>
9. <plugins>
10. <plugin>
11. <groupId>org.apache.maven.plugins</groupId>
12. <artifactId>maven-compiler-plugin</artifactId>
13. <version>2.0.2</version>
14. <configuration>
15. <source>1.6</source>
16. <target>1.6</target>
17. </configuration>
18. </plugin>
19. <plugin>
20. <groupId>org.mortbay.jetty</groupId>
21. <artifactId>maven-jetty-plugin</artifactId>
22. <version>6.1.14</version>
23. </plugin>
24. </plugins>
25. </build>
26.
27. <dependencies>
28. <dependency>
29. <groupId>javax.servlet</groupId>
30. <artifactId>servlet-api</artifactId>
31. <version>2.5</version>
32. <type>jar</type>
33. <scope>provided</scope>
34. </dependency>
35. <dependency>
36. <groupId>org.springframework</groupId>
37. <artifactId>spring</artifactId>
38. <version>2.5.6</version>
39. <type>jar</type>
40. <scope>compile</scope>
41. </dependency>
42. <dependency>
43. <groupId>org.aspectj</groupId>
44. <artifactId>aspectjrt</artifactId>
45. <version>1.6.2</version>
46. <type>jar</type>
47. <scope>compile</scope>
48. </dependency>
49. <dependency>
50. <groupId>org.aspectj</groupId>
51. <artifactId>aspectjweaver</artifactId>
52. <version>1.6.2</version>
53. <type>jar</type>
54. <scope>compile</scope>
55. </dependency>
56. <dependency>
57. <groupId>org.apache.struts</groupId>
58. <artifactId>struts2-core</artifactId>
59. <version>2.0.14</version>
60. <type>jar</type>
61. <scope>compile</scope>
62. </dependency>
63. <dependency>
64. <groupId>org.apache.struts</groupId>
65. <artifactId>struts2-spring-plugin</artifactId>
66. <version>2.0.14</version>
67. <type>jar</type>
68. <scope>compile</scope>
69. <exclusions>
70. <exclusion>
71. <artifactId>spring-beans</artifactId>
72. <groupId>org.springframework</groupId>
73. </exclusion>
74. <exclusion>
75. <artifactId>spring-core</artifactId>
76. <groupId>org.springframework</groupId>
77. </exclusion>
78. <exclusion>
79. <artifactId>spring-context</artifactId>
80. <groupId>org.springframework</groupId>
81. </exclusion>
82. <exclusion>
83. <artifactId>spring-web</artifactId>
84. <groupId>org.springframework</groupId>
85. </exclusion>
86. </exclusions>
87. </dependency>
88. <dependency>
89. <groupId>org.hibernate</groupId>
90. <artifactId>hibernate</artifactId>
91. <version>3.2.6.ga</version>
92. <type>jar</type>
93. <scope>compile</scope>
94. </dependency>
95. <dependency>
96. <groupId>mysql</groupId>
97. <artifactId>mysql-connector-java</artifactId>
98. <version>5.1.6</version>
99. <type>jar</type>
100. <scope>runtime</scope>
101. </dependency>
102. <dependency>
103. <groupId>c3p0</groupId>
104. <artifactId>c3p0</artifactId>
105. <version>0.9.1.2</version>
106. <type>jar</type>
107. <scope>compile</scope>
108. </dependency>
109. <dependency>
110. <groupId>log4j</groupId>
111. <artifactId>log4j</artifactId>
112. <version>1.2.14</version>
113. <type>jar</type>
114. <scope>compile</scope>
115. </dependency>
116. <dependency>
117. <groupId>cglib</groupId>
118. <artifactId>cglib-nodep</artifactId>
119. <version>2.1_3</version>
120. <type>jar</type>
121. <scope>compile</scope>
122. </dependency>
123. </dependencies>
124. </project>
<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>org.eagle</groupId>
<artifactId>ssh-base</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.14</version>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.5.6</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.6.2</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.6.2</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.0.14</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-spring-plugin</artifactId>
<version>2.0.14</version>
<type>jar</type>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>spring-beans</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>spring-core</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>spring-context</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>spring-web</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
<version>3.2.6.ga</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
<type>jar</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>c3p0</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.1.2</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<version>2.1_3</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
3.添加基本的配置文件
src/main/resources/applicationContext.xml
Xml代码
1. <?xml version="1.0" encoding="UTF-8"?>
2. <beans xmlns="http://www.springframework.org/schema/beans"
3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
4. xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
5. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
6. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
7. http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
8. http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
9. <context:property-placeholder location="WEB-INF/config/jdbc.properties" />
10.
11. <!-- 定义数据源Bean,使用C3P0数据源实现 -->
12. <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
13. destroy-method="close">
14. <!-- 指定连接数据库的驱动 -->
15. <property name="driverClass" value="${jdbc.driverClassName}" />
16. <!-- 指定连接数据库的URL -->
17. <property name="jdbcUrl" value="${jdbc.url}" />
18. <!-- 指定连接数据库的用户名 -->
19. <property name="user" value="${jdbc.username}" />
20. <!-- 指定连接数据库的密码 -->
21. <property name="password" value="${jdbc.password}" />
22. <!-- 指定连接数据库连接池的最大连接数 -->
23. <property name="maxPoolSize" value="20" />
24. <!-- 指定连接数据库连接池的最小连接数 -->
25. <property name="minPoolSize" value="1" />
26. <!-- 指定连接数据库连接池的初始化连接数 -->
27. <property name="initialPoolSize" value="1" />
28. <!-- 指定连接数据库连接池的连接的最大空闲时间 -->
29. <property name="maxIdleTime" value="20" />
30. </bean>
31.
32. <bean id="sessionFactory"
33. class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
34. <property name="dataSource" ref="dataSource" />
35. <property name="mappingDirectoryLocations">
36. <list>
37. <value>classpath:org/eagle/orm</value>
38. </list>
39. </property>
40. <property name="hibernateProperties">
41. <props>
42. <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect
43. </prop>
44. <prop key="show_sql">true</prop>
45. <prop key="hibernate.hbm2ddl.auto">update</prop>
46. <prop key="hibernate.jdbc.batch_size">20</prop>
47. </props>
48. </property>
49. </bean>
50.
51. <!-- 配置事务管理器 -->
52. <bean id="transactionManager"
53. class="org.springframework.orm.hibernate3.HibernateTransactionManager">
54. <property name="sessionFactory" ref="sessionFactory" />
55. </bean>
56.
57. <!-- 配置事务的传播性 -->
58. <tx:advice id="txAdvice" transaction-manager="transactionManager">
59. <tx:attributes>
60. <tx:method name="add*" propagation="REQUIRED" />
61. <tx:method name="del*" propagation="REQUIRED" />
62. <tx:method name="modify*" propagation="REQUIRED" />
63. <tx:method name="*" read-only="true" />
64. </tx:attributes>
65. </tx:advice>
66.
67. <!-- 配置哪些类哪些方法使用事务 -->
68. <aop:config>
69. <!-- 配置切入点(定义哪些方法要进行事务处理) -->
70. <aop:pointcut id="allManager"
71. expression="execution(* org.eagle.services..*.*(..))" />
72. <!-- 定义advice -->
73. <aop:advisor advice-ref="txAdvice" pointcut-ref="allManager" />
74. </aop:config>
75.
76. </beans>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
<context:property-placeholder location="WEB-INF/config/jdbc.properties" />
<!-- 定义数据源Bean,使用C3P0数据源实现 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<!-- 指定连接数据库的驱动 -->
<property name="driverClass" value="${jdbc.driverClassName}" />
<!-- 指定连接数据库的URL -->
<property name="jdbcUrl" value="${jdbc.url}" />
<!-- 指定连接数据库的用户名 -->
<property name="user" value="${jdbc.username}" />
<!-- 指定连接数据库的密码 -->
<property name="password" value="${jdbc.password}" />
<!-- 指定连接数据库连接池的最大连接数 -->
<property name="maxPoolSize" value="20" />
<!-- 指定连接数据库连接池的最小连接数 -->
<property name="minPoolSize" value="1" />
<!-- 指定连接数据库连接池的初始化连接数 -->
<property name="initialPoolSize" value="1" />
<!-- 指定连接数据库连接池的连接的最大空闲时间 -->
<property name="maxIdleTime" value="20" />
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="mappingDirectoryLocations">
<list>
<value>classpath:org/eagle/orm</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect
</prop>
<prop key="show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="hibernate.jdbc.batch_size">20</prop>
</props>
</property>
</bean>
<!-- 配置事务管理器 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- 配置事务的传播性 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED" />
<tx:method name="del*" propagation="REQUIRED" />
<tx:method name="modify*" propagation="REQUIRED" />
<tx:method name="*" read-only="true" />
</tx:attributes>
</tx:advice>
<!-- 配置哪些类哪些方法使用事务 -->
<aop:config>
<!-- 配置切入点(定义哪些方法要进行事务处理) -->
<aop:pointcut id="allManager"
expression="execution(* org.eagle.services..*.*(..))" />
<!-- 定义advice -->
<aop:advisor advice-ref="txAdvice" pointcut-ref="allManager" />
</aop:config>
</beans>
src/main/resources/struts.xml
Xml代码
1. <?xml version="1.0" encoding="UTF-8"?>
2.
3. <!DOCTYPE struts PUBLIC
4. "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
5. "http://struts.apache.org/dtds/struts-2.0.dtd">
6.
7. <struts>
8.
9. </struts>
<?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>
</struts>
src/main/webapp/WEB-INF/config/jdbc.properties
Java代码
1. jdbc.driverClassName=com.mysql.jdbc.Driver
2. jdbc.url=jdbc:mysql://localhost:3306/shs2
3. jdbc.username=root
4. jdbc.password=ubuntu
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/shs2
jdbc.username=root
jdbc.password=ubuntu
src/main/webapp/WEB-INF/config/log4j.properties
Java代码
1. log4j.rootLogger=INFO, stdout, logfile
2.
3. log4j.appender.stdout=org.apache.log4j.ConsoleAppender
4. log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
5. log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n
6.
7. log4j.appender.logfile=org.apache.log4j.RollingFileAppender
8. log4j.appender.logfile.File=${webapp.root}/WEB-INF/logs/pcdiy.log
9. log4j.appender.logfile.MaxFileSize=512KB
10. # Keep three backup files.
11. log4j.appender.logfile.MaxBackupIndex=3
12. # Pattern to output: date priority [category] - message
13. log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
14. log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n
log4j.rootLogger=INFO, stdout, logfile
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n
log4j.appender.logfile=org.apache.log4j.RollingFileAppender
log4j.appender.logfile.File=${webapp.root}/WEB-INF/logs/pcdiy.log
log4j.appender.logfile.MaxFileSize=512KB
# Keep three backup files.
log4j.appender.logfile.MaxBackupIndex=3
# Pattern to output: date priority [category] - message
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n
4.web.xml
Xml代码
1. <?xml version="1.0" encoding="UTF-8"?>
2. <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3. xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
4. xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
5. id="WebApp_ID" version="2.5">
6.
7. <context-param>
8. <param-name>contextConfigLocation</param-name>
9. <param-value>classpath:applicationContext.xml</param-value>
10. </context-param>
11.
12. <context-param>
13. <param-name>log4jConfigLocation</param-name>
14. <param-value>/WEB-INF/config/log4j.properties</param-value>
15. </context-param>
16. <filter>
17. <filter-name>struts2</filter-name>
18. <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
19. </filter>
20. <filter-mapping>
21. <filter-name>struts2</filter-name>
22. <url-pattern>/*</url-pattern>
23. </filter-mapping>
24.
25. <listener>
26. <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
27. </listener>
28. <listener>
29. <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
30. </listener>
31. </web-app>
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/config/log4j.properties</param-value>
</context-param>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
</web-app>
5.基本上可以,现在来生成archetype的目录结构(假设工程在/home/lingshangwen/project/ssh-base)
进入到工程的根目录ssh-base下
$cd ~/project/ssh-base
$mvn archetype:create-from-project
运行完该命令后,将会有如下的目录~/project/ssh-base/target/generated-sources/archetype
6.创建archetype
$cd ~/project/ssh-base/target/generated-sources/archetype
$mvn install
到现在为止,我想要的ssh的archetype创建出来了,如何通过该archetype创建项目呢,很简单,看看
$cd ~/project
$mvn archetype:generate
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO] task-segment: [archetype:generate] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] Preparing archetype:generate
[INFO] No goals needed for project - skipping
[INFO] Setting property: classpath.resource.loader.class => 'org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader'.
[INFO] Setting property: velocimacro.messages.on => 'false'.
[INFO] Setting property: resource.loader => 'classpath'.
[INFO] Setting property: resource.manager.logwhenfound => 'false'.
[INFO] [archetype:generate]
[INFO] Generating project in Interactive mode
[INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0)
Choose archetype:
1: local -> ssh (null)
2: local -> ssh-base-archetype (ssh-base-archetype)
3: internal -> appfuse-basic-jsf (AppFuse archetype for creating a web application with Hibernate, Spring and JSF)
4: internal -> appfuse-basic-spring (AppFuse archetype for creating a web application with Hibernate, Spring and Spring MVC)
5: internal -> appfuse-basic-struts (AppFuse archetype for creating a web application with Hibernate, Spring and Struts 2)
6: internal -> appfuse-basic-tapestry (AppFuse archetype for creating a web application with Hibernate, Spring and Tapestry 4)
7: internal -> appfuse-core (AppFuse archetype for creating a jar application with Hibernate and Spring and XFire)
8: internal -> appfuse-modular-jsf (AppFuse archetype for creating a modular application with Hibernate, Spring and JSF)
9: internal -> appfuse-modular-spring (AppFuse archetype for creating a modular application with Hibernate, Spring and Spring MVC)
10: internal -> appfuse-modular-struts (AppFuse archetype for creating a modular application with Hibernate, Spring and Struts 2)
11: internal -> appfuse-modular-tapestry (AppFuse archetype for creating a modular application with Hibernate, Spring and Tapestry 4)
12: internal -> maven-archetype-j2ee-simple (A simple J2EE Java application)
13: internal -> maven-archetype-marmalade-mojo (A Maven plugin development project using marmalade)
14: internal -> maven-archetype-mojo (A Maven Java plugin development project)
15: internal -> maven-archetype-portlet (A simple portlet application)
16: internal -> maven-archetype-profiles ()
17: internal -> maven-archetype-quickstart ()
18: internal -> maven-archetype-site-simple (A simple site generation project)
19: internal -> maven-archetype-site (A more complex site project)
20: internal -> maven-archetype-webapp (A simple Java web application)
21: internal -> jini-service-archetype (Archetype for Jini service project creation)
22: internal -> softeu-archetype-seam (JSF+Facelets+Seam Archetype)
23: internal -> softeu-archetype-seam-simple (JSF+Facelets+Seam (no persistence) Archetype)
24: internal -> softeu-archetype-jsf (JSF+Facelets Archetype)
25: internal -> jpa-maven-archetype (JPA application)
26: internal -> spring-osgi-bundle-archetype (Spring-OSGi archetype)
27: internal -> confluence-plugin-archetype (Atlassian Confluence plugin archetype)
28: internal -> jira-plugin-archetype (Atlassian JIRA plugin archetype)
29: internal -> maven-archetype-har (Hibernate Archive)
30: internal -> maven-archetype-sar (JBoss Service Archive)
31: internal -> wicket-archetype-quickstart (A simple Apache Wicket project)
32: internal -> scala-archetype-simple (A simple scala project)
33: internal -> lift-archetype-blank (A blank/empty liftweb project)
34: internal -> lift-archetype-basic (The basic (liftweb) project)
35: internal -> cocoon-22-archetype-block-plain ([http://cocoon.apache.org/2.2/maven-plugins/])
36: internal -> cocoon-22-archetype-block ([http://cocoon.apache.org/2.2/maven-plugins/])
37: internal -> cocoon-22-archetype-webapp ([http://cocoon.apache.org/2.2/maven-plugins/])
38: internal -> myfaces-archetype-helloworld (A simple archetype using MyFaces)
39: internal -> myfaces-archetype-helloworld-facelets (A simple archetype using MyFaces and facelets)
40: internal -> myfaces-archetype-trinidad (A simple archetype using Myfaces and Trinidad)
41: internal -> myfaces-archetype-jsfcomponents (A simple archetype for create custom JSF components using MyFaces)
42: internal -> gmaven-archetype-basic (Groovy basic archetype)
43: internal -> gmaven-archetype-mojo (Groovy mojo archetype)
Choose a number: (1/2/3/4/5/6/7/8/9/10/11/12/13/14/15/16/17/18/19/20/21/22/23/24/25/26/27/28/29/30/31/32/33/34/35/36/37/38/39/40/41/42/43) 17: :
ssh-base的archetype为2,故选择2
~~有个这个archetype以后创建ssh项目就快多了
相关推荐
Maven 中有许多内置的 archetype,也可以从 Maven 中央仓库或其他仓库中查找第三方 archetype。 2. **配置 Archetype**:在 Maven 的命令行中,使用 `mvn archetype:generate` 命令,然后按照提示输入 archetype 的...
【maven】多子模块maven模板工程archetype创建过程 在软件开发中,Maven作为Java项目管理和构建工具,提供了强大的依赖管理功能。而Maven的Archetype插件则可以帮助开发者快速创建新项目的模板,尤其对于有多个子...
`maven-archetype-quickstart-1.1.jar` 是一个Maven的快速启动 archetype 包,专门用于帮助开发者快速创建一个新的Maven项目结构。在这个压缩包中,你将找到一个预设的Java项目模板,以便于你能够迅速地开始编码。 ...
4. **可扩展性**:除了基础配置,开发者还可以根据自己的需求添加或修改archetype中的内容,比如添加特定的框架或者库,以满足不同项目的需求。 5. **便捷的生成方式**:通过Maven的命令行工具,开发者只需要输入几...
2021-10-28官网下载archetype-catalog.xml。(maven项目快速搭建,缺少这个文件时,提示maven-archetype-webapp could not resolve archetpye)
eclipse创建maven工程时无法创建,缺少的jar
1. **标准化项目结构**:Archetype 提供了一种标准的方式来创建具有预定义目录结构的新 Maven 项目,确保了团队间的一致性。 2. **快速启动项目**:基于已有的 Archetype,开发者可以迅速初始化项目,而不必手动创建...
Maven逆向工程是一种技术手段,主要用于从已有的Java项目中恢复构建过程,即从已编译的类中重建源代码的Maven项目结构。在软件开发过程中,有时我们可能需要处理没有完整源码或者缺少构建配置的遗留项目,此时Maven...
【使用Maven搭建S2SH工程详解一:创建Struts2工程】 在Java Web开发中,S2SH架构(Struts2 + Spring + Hibernate)是一种常见的应用框架组合,用于构建高效、灵活的企业级应用程序。本篇文章主要讲解如何利用Maven...
1. 快速启动:Archetype可以为新项目提供一个基本的框架,无需从零开始创建目录和文件。 2. 规范化:不同类型的项目有不同的结构需求,Archetype确保项目遵循最佳实践和行业标准。 3. 自定义:开发者可以创建自己的...
《 Maven Archetype Catalog:加速Eclipse中的Maven项目创建 》 在软件开发过程中,Maven作为Java项目管理工具,其强大的依赖管理和构建能力深受开发者喜爱。然而,当我们使用Eclipse这样的集成开发环境(IDE)时,...
2. 使用archetype:generate命令:通过执行`mvn archetype:generate`命令,开发者可以基于maven-archetype-3.1.2创建新项目,输入相应的ID和属性值,即可自动生成符合规范的新项目结构。 三、依赖管理和插件配置 1....
描述中提到的"博文链接",虽然具体内容无法在此提供,但通常这样的博客会详细讲解如何创建一个简单的"Maven项目",从零开始,包括编写`pom.xml`文件,这是Maven项目的核心配置文件。`pom.xml`文件定义了项目的属性,...
1. **下载**: 从 Apache Maven 官方网站下载最新或特定版本的 Maven,如 apache-maven-3.0.5.zip。 2. **解压**: 解压缩下载的 zip 文件到指定目录,如 `C:\Program Files`。 3. **配置环境变量**: 配置 `M2_HOME` ...
本篇文章将深入探讨如何使用Maven命令来创建工程、打包工程以及掌握一些常用的Maven命令。 首先,让我们了解Maven的核心概念。Maven基于项目对象模型(Project Object Model,POM),这是一个XML文件,包含了项目的...
Maven是Java项目管理工具,archetype是Maven中的一个概念,用于创建项目模板。通过指定特定的archetype,开发者可以快速生成符合特定结构和配置的项目骨架,SSM的maven archetype就是这样一种模板,它可以自动生成...
Maven Archetype Catalog是Maven生态系统中的一个重要组成部分,它提供了一种快速创建新Maven项目的模板集合。这个名为"archetype-catalog.zip"的压缩包文件,实际上是一个Maven Archetype目录的归档,包含了多个...
1. **依赖管理**:Maven能够自动处理项目中所有依赖的解析、下载和更新,确保项目构建的一致性和可复现性。 2. **项目信息管理**:Maven使用`pom.xml`(Project Object Model)文件来描述项目的基本信息,包括项目...
使用Maven,开发者可以利用命令行工具进行各种操作,如初始化项目(`mvn archetype:create`)、编译源代码(`mvn compile`)、运行测试(`mvn test`)、打包应用(`mvn package`)、安装到本地仓库(`mvn install`)...