- 浏览: 61231 次
- 性别:
- 来自: 广州
最新评论
-
zxjlwt:
学习了。http://surenpi.com
python:在python中使用opencv进行摄像头编程初体验 -
lingshangwen:
http://www.opencv.org.cn/index. ...
python:在python中使用opencv进行摄像头编程初体验 -
fengsage:
能给下python opencv的下载地址吗?
python:在python中使用opencv进行摄像头编程初体验
最近用spring2.5.6+hibernate3.2+struts2.0.14做项目,用这些框架做项目最鬼麻烦的就是搭建工程的基本原型,为了在以后不用在这么麻烦,于是就有了创建一个自己的ssh的archetype的念头,说干就干,开始动手。
1.创建一个maven项目(在eclipse 中通过m2eclipse创建或者用mvn archetype:genetate命令创建)。
2.添加spring,hibernate,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>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 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 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
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
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 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项目就快多了
发表评论
-
ubuntu下安装Memcache
2009-11-26 21:24 1150下载memcached : http://danga.com/ ... -
python编码
2009-10-21 13:48 0m = {"id":12560271 ... -
python:Queue模块
2009-10-05 23:03 1493queue — A synchronized que ... -
Python调用C语言函数
2009-08-03 11:39 3198使用Python的ctypes,我们可以直接调用由C直接编译出 ... -
python:在python中使用opencv进行摄像头编程初体验
2009-07-19 11:22 17653闲着没事做,前段时间买了个摄像头,在ubuntu上用。打开ch ... -
使用freemarker
2009-06-21 00:08 932public class Student { p ... -
wxPython:初识wx.Frame
2009-06-10 23:11 1297parent :框架的父窗口。对于顶级窗口,这个值是None ... -
oracle:进行分组并取每组中的前n条记录
2009-05-19 22:56 3794题目: 在oracle中有一数据表exam_result(成 ... -
python:pymedia安装
2009-05-16 00:00 4437"Pymedia is a Python libra ... -
maven2:安装篇
2009-05-06 23:13 1896下载maven2:http://www.apache.org/ ... -
pygame新手指南
2009-04-12 01:50 2273pygame新手指南 ——zzj译 原文出处 ... -
struts2.1.X中使用datetimepicker
2009-03-22 21:56 1897添加dojo依赖 <dependency> ...
相关推荐
maven_archetype maven的文件,有需要的就下載吧 壓縮格式為.7z檔
在apache-maven-3.5.2/conf/setting.xml中加入以下配置即可解决 alimaven aliyun maven http://maven.aliyun.com/nexus/content/repositories/central/ central junit junit Address/ ...
使用Maven搭建S2SH工程详解一:使用Maven创建struts2工程
2021-10-28官网下载archetype-catalog.xml。(maven项目快速搭建,缺少这个文件时,提示maven-archetype-webapp could not resolve archetpye)
MAVEN安装包:apache-maven-3.0.5.zip
Maven 教程:基础篇——尚硅谷学习笔记 2022年
NULL 博文链接:https://singleant.iteye.com/blog/1470663
官网链接地址:http://repo1.maven.org/maven2/archetype-catalog.xml 百度云链接:https://pan.baidu.com/s/1dF8Qa9V 密码:37me
maven-archetype-webapp-1.0.jar,下载,如果有需要的同志可以自己下载,。
2.cmd窗口执行mvn install:install-file -DgroupId=org.apache.maven.archetypes -DartifactId=maven-archetype-quickstart -Dversion=1.1 -Dpackaging=jar -Dfile=maven-archetype-quickstart-1.1.jar
Eclipse Maven 创建Web 项目报错 Could not resolve archetype org.apache.maven.archetypes:maven-archetype-webap 之前找了很久才找到了,传上来更大家共享下,希望对大家有帮助,欢迎下载或者永久保存。
用maven命令mvn archetype:generate创建工程的时候,如果遇到明明本地仓库repository已经有相关jar,却报archetype错误,无法创建工程,很有可能是maven的插件archetype有问题。请下载此资源,替换掉.m2下USER_HOME/...
自己实现的自定义maven插件:可以根据配置的接口类和参数类,生成对应的word版本的API文档。还可以自定义自己的模板文件。
Downloading from central: https://repo1.maven.org/maven2/org/apache/maven/plugins/maven-archetype-plugin/maven-metadata.xml 很奇怪,我的maven仓库配置了私有库,,并且在maven setting.xml中配置了mirror...
maven版本
【在本地库中装载maven-archetype-quickstart】 1. 下载该文件 2. 打开cmd窗口,执行mvn install:install-file -DgroupId=org.apache.maven.archetypes -DartifactId=maven-archetype-quickstart -Dversion=1.1 -...
maven archetype-catalog.xml, 创建maven项目更快。
IDEA maven创建servlet3.1 webapp工程模版
zookeeper_demo maven项目:包含原生API、zkclient、Curator操作,并包含集群、分布锁等操作
Apache Maven是一个软件项目管理和理解工具。 基于项目对象模型(POM)的概念,Maven可以从中心信息中管理项目的构建、报告和文档。