zoukankan      html  css  js  c++  java
  • 学习《The Flex, Spring, and BlazeDS full stack》-1

    学习《The Flex, Spring, and BlazeDS full stack》,使用maven flexmojos spring struts2 hibernate blazeDS创建多模块项目

    flexmojos的最新版4.0-SNAPSHOT需要maven3,所以使用apache-maven-3.0-beta-2。。。

    一.创建父项目
    1.使用
    mvn -DgroupId=org.adaikiss.kay -DartifactId=kay archetype:generate
    创建父项目骨架,并做以下修改:
    (1)删除kay目录下的src文件夹;
    (2)编辑pom.xml将packaging由jar改为pom;
    (3)编辑pom.xml添加以下内容

    <repositories>
    <repository>
    <id>flex-mojos-repository</id>
    <url>http://repository.sonatype.org/content/groups/flexgroup</url>
    <releases>
    <enabled>true</enabled>
    </releases>
    <snapshots>
    <enabled>true</enabled>
    </snapshots>
    </repository>
    <repository>
    <id>epseelon-repository</id>
    <url>http://m2repo.epseelon.org/</url>
    <releases>
    <enabled>true</enabled>
    </releases>
    <snapshots>
    <enabled>true</enabled>
    </snapshots>
    </repository>
    </repositories>
    <pluginRepositories>
    <pluginRepository>
    <id>flex-mojos-repository</id>
    <url>http://repository.sonatype.org/content/groups/flexgroup</url>
    <releases>
    <enabled>true</enabled>
    </releases>
    <snapshots>
    <enabled>true</enabled>
    </snapshots>
    </pluginRepository>
    <pluginRepository>
    <id>epseelon-repository</id>
    <url>http://m2repo.epseelon.org/</url>
    <releases>
    <enabled>true</enabled>
    </releases>
    <snapshots>
    <enabled>true</enabled>
    </snapshots>
    </pluginRepository>
    </pluginRepositories>
    <build>
    <pluginManagement>
    <plugins>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>2.0</version>
    </plugin>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>2.2-beta-2</version>
    </plugin>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-eclipse-plugin</artifactId>
    <version>2.8</version>
    <configuration>
    <sourceExcludes>
    <sourceExclude>**/.svn/</sourceExclude>
    </sourceExcludes>
    <downloadSources>true</downloadSources>
    </configuration>
    </plugin>
    </plugins>
    </pluginManagement>
    </build>

    二.创建flex项目模块
    1.打开cmd定位到kay目录,运行如下命令
    mvn archetype:generate -DarchetypeRepository=http://repository.sonatype.com/content/groups/flexgroup -DarchetypeGroupId=org.sonatype.flexmojos -DarchetypeArtifactId=flexmojos-archetypes-application -DarchetypeVersion=4.0-SNAPSHOT -DgroupId=org.adaikiss.kay -DartifactId=flex -Dpackagename=org.adaikiss.kay2.修改pom.xml,删除junit依赖,并修改plugin节点为以下内容
      

    <plugin>
    <groupId>org.sonatype.flexmojos</groupId>
    <artifactId>flexmojos-maven-plugin</artifactId>
    <version>4.0-SNAPSHOT</version>
    <extensions>true</extensions>
    <configuration>
    <!-- put your configuration options here -->
    <debug>true</debug>
    <allowSourcePathOverlap>true</allowSourcePathOverlap>
    </configuration>
    </plugin>

    3.在cmd中进入kay目录,运行mvn install -DskipTests,当出现build success后进入flex/target目录,找到flex-1.0.swf并运行,出现"hello world!"表示成功!

    三.创建java web项目模块
    1.打开cmd定位到kay目录,运行以下命令
    mvn archetype:generate -DgroupId=org.adaikiss.kay -DartifactId=web -Dpackagename=org.adaikiss.kay -DarchetypeArtifactId=maven-archetype-webapp
    2.修改pom.xml,添加以下内容到build节点,以指定java编译器版本

    <plugins>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
    <source>1.6</source>
    <target>1.6</target>
    </configuration>
    </plugin>
    </plugins>

       
    再添加以下内容,以将配置文件包含进web应用
    <resources>
    <resource>
    <directory>src/main/resources</directory>
    </resource>
    <resource>
    <directory>src/main/java</directory>
    <excludes>
    <exclude>**/*.java</exclude>
    </excludes>
    <includes>
    <include>**/*.xml</include>
    </includes>
    </resource>
    </resources>

    四.创建用于共享配置文件的模块
    1.打开cmd定位到kay目录,运行以下命令
    mvn archetype:generate -DgroupId=org.adaikiss.kay -DartifactId=config
    2.进入config目录,删除其中src/main/java和src/test.然后创建目录src/main/resources,将blazeds.war中的WEB-INF\flex\目录里的以下5个文件复制到resources目录
    messaging-config.xml
    proxy-config.xml
    remoting-config.xml
    services-config.xml
    version.properties
    3.修改pom.xml,删除junit依赖,添加以下内容

    <packaging>pom</packaging>
    <build>
    <plugins>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-assembly-plugin</artifactId>
    <executions>
    <execution>
    <id>make shared resources</id>
    <goals>
    <goal>single</goal>
    </goals>
    <phase>package</phase>
    <configuration>
    <descriptors>
    <descriptor>src/main/assembly/resources.xml</descriptor>
    </descriptors>
    </configuration>
    </execution>
    </executions>
    </plugin>
    </plugins>
    </build>

    4.创建src/main/assembly/resources.xml,代码如下
    <assembly>
    <id>resources</id>
    <formats>
    <format>zip</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>
    <fileSets>
    <fileSet>
    <directory>src/main/resources</directory>
    <outputDirectory></outputDirectory>
    </fileSet>
    </fileSets>
    </assembly>

    五.设置各模块间的依赖
    1.将config作为web模块依赖项包含到web中,在web/pom.xml中的dependencies节点添加以下代码
       

    <dependency>
    <groupId>${project.groupId}</groupId>
    <artifactId>config</artifactId>
    <version>${project.version}</version>
    <classifier>resources</classifier>
    <type>zip</type>
    <scope>provided</scope>
    </dependency>

    2.在build节点添加以下内容
           

    <plugin>
    <artifactId>maven-dependency-plugin</artifactId>
    <executions>
    <execution>
    <id>unpack-config</id>
    <goals>
    <goal>unpack-dependencies</goal>
    </goals>
    <phase>generate-resources</phase>
    <configuration>
    <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/flex</outputDirectory>
    <includeArtifacIds>config</includeArtifacIds>
    <includeGroupIds>${project.groupId}</includeGroupIds>
    <includeClassifiers>resources</includeClassifiers>
    <excludeTransitive>true</excludeTransitive>
    <excludeTypes>jar,swf</excludeTypes>
    </configuration>
    </execution>
    </executions>
    </plugin>

           
    3.将配置文件共享模块config添加为flex依赖项
           
    <dependency>
    <groupId>${project.groupId}</groupId>
    <artifactId>config</artifactId>
    <version>${project.version}</version>
    <classifier>resources</classifier>
    <type>zip</type>
    <scope>provided</scope>
    </dependency>

           
    4.配置插件使之能够将配置文件解压到resources文件夹下,在flex/pom.xml添加以下代码
      
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <executions>
    <execution>
    <id>unpack-config</id>
    <goals>
    <goal>unpack-dependencies</goal>
    </goals>
    <phase>generate-resources</phase>
    <configuration>
    <outputDirectory>${project.build.directory}/generated-resources</outputDirectory>
    <includeArtifacIds>config</includeArtifacIds>
    <includeGroupIds>${project.groupId}</includeGroupIds>
    <excludeTransitive>true</excludeTransitive>
    </configuration>
    </execution>
    </executions>
    </plugin>

    5.在flex/pom.xml的build元素中添加以下代码将target/generated-resources添加到默认的resources
      
    <resources>
    <resource>
    <directory>${basedir}/src/main/resources</directory>
    </resource>
    <resource>
    <directory>${basedir}/target/generated-resources</directory>
    <filtering>true</filtering>
    </resource>
    </resources>

       
    6.在flex/pom.xml中修改flex-compiler-mojo的配置信息,在configuration节点添加以下代码代码
    <contextRoot>todolist-web</contextRoot>
    7.将Flex UI打包进Web应用,将flex作为依赖项添加到web中。添加以下配置到web/pom.xml
       
    <dependency>
    <groupId>${project.groupId}</groupId>
    <artifactId>flex</artifactId>
    <version>${project.version}</version>
    <type>swf</type>
    </dependency>

       
    8.为了将依赖拷贝到Web压缩包中,我们还需要配置maven-dependency-plugin。在web/pom.xml中添加以下maven-dependency-plugin配置代码
          
    <execution>
    <id>copy-swf</id>
    <phase>process-classes</phase>
    <goals>
    <goal>copy-dependencies</goal>
    </goals>
    <configuration>
    <outputDirectory>${project.build.directory}/${project.build.finalName}/swf</outputDirectory>
    <includeTypes>swf</includeTypes>
    </configuration>
    </execution>

    六.给web模块添加spring/struts2/hibernate/jetty支持,参考springside

    1.在kay/pom.xml中添加以下节点,预定义一些依赖的版本

    <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <spring.version>3.0.3.RELEASE</spring.version>
    <hibernate.version>3.3.2.GA</hibernate.version>
    <struts2.version>2.1.8.1</struts2.version>
    <h2.version>1.2.139</h2.version>
    <quartz.version>1.8.3</quartz.version>
    <slf4j.version>1.6.1</slf4j.version>
    <cxf.version>2.2.9</cxf.version>
    <jersey.version>1.3</jersey.version>
    <spring-security.version>3.0.3.RELEASE</spring-security.version>
    <activemq.version>5.3.2</activemq.version>
    <jetty.version>6.1.24</jetty.version>
    <h2.version>1.2.139</h2.version>
    <quartz.version>1.8.3</quartz.version>
    <jackson.version>1.5.4</jackson.version>
    <slf4j.version>1.6.1</slf4j.version>
    <selenium.version>2.0a4</selenium.version>
    </properties>

    2.在repositories节点中添加以下仓库

    <repository>
    <id>jboss</id>
    <name>Jboss Repository</name>
    <url>http://repository.jboss.com/maven2</url>
    <snapshots>
    <enabled>false</enabled>
    </snapshots>
    </repository>

    <repository>
    <id>java.net</id>
    <name>Java.net Repository</name>
    <url>http://download.java.net/maven/2/</url>
    <snapshots>
    <enabled>false</enabled>
    </snapshots>
    </repository>

    <repository>
    <id>spy</id>
    <name>Spy Repository</name>
    <url>http://bleu.west.spy.net/~dustin/m2repo/</url>
    <snapshots>
    <enabled>false</enabled>
    </snapshots>
    </repository>

    <repository>
    <id>jmemcached</id>
    <name>JMemcached Repository</name>
    <url>http://thimbleware.com/maven</url>
    <snapshots>
    <enabled>false</enabled>
    </snapshots>
    </repository>

    3.在根节点添加以下依赖

    <dependencyManagement>
    <dependencies>
    <!-- spring begin -->
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>${spring.version}</version>
    </dependency>
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-beans</artifactId>
    <version>${spring.version}</version>
    </dependency>
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
    <version>${spring.version}</version>
    </dependency>

    <!-- spring aop -->
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-aop</artifactId>
    <version>${spring.version}</version>
    </dependency>
    <dependency>
    <groupId>org.aspectj</groupId>
    <artifactId>aspectjweaver</artifactId>
    <version>1.6.9</version>
    </dependency>
    <dependency>
    <groupId>cglib</groupId>
    <artifactId>cglib-nodep</artifactId>
    <version>2.2</version>
    </dependency>
    <!-- spring end -->

    <!-- database access begin -->
    <!-- hibernate -->
    <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>${hibernate.version}</version>
    </dependency>
    <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-annotations</artifactId>
    <version>3.4.0.GA</version>
    </dependency>
    <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-ehcache</artifactId>
    <version>${hibernate.version}</version>
    </dependency>
    <!-- newest version in jboss repository -->
    <dependency>
    <groupId>javassist</groupId>
    <artifactId>javassist</artifactId>
    <version>3.11.0.GA</version>
    </dependency>

    <!-- spring orm -->
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-orm</artifactId>
    <version>${spring.version}</version>
    </dependency>

    <!-- optional datasource-->
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-jdbc</artifactId>
    <version>${spring.version}</version>
    </dependency>

    <dependency>
    <groupId>commons-dbcp</groupId>
    <artifactId>commons-dbcp</artifactId>
    <version>1.4</version>
    </dependency>
    <!-- database access end -->

    <!-- web begin -->
    <!-- struts2 -->
    <dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-core</artifactId>
    <version>${struts2.version}</version>
    <exclusions>
    <exclusion>
    <groupId>com.sun</groupId>
    <artifactId>tools</artifactId>
    </exclusion>
    </exclusions>
    </dependency>
    <dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-spring-plugin</artifactId>
    <version>${struts2.version}</version>
    </dependency>
    <dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-convention-plugin</artifactId>
    <version>${struts2.version}</version>
    </dependency>
    <dependency>
    <groupId>org.freemarker</groupId>
    <artifactId>freemarker</artifactId>
    <version>2.3.16</version>
    </dependency>

    <!-- spring web -->
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web</artifactId>
    <version>${spring.version}</version>
    </dependency>
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
    <version>${spring.version}</version>
    </dependency>

    <!-- json -->
    <dependency>
    <groupId>org.codehaus.jackson</groupId>
    <artifactId>jackson-core-asl</artifactId>
    <version>${jackson.version}</version>
    </dependency>
    <dependency>
    <groupId>org.codehaus.jackson</groupId>
    <artifactId>jackson-mapper-asl</artifactId>
    <version>${jackson.version}</version>
    </dependency>
    <dependency>
    <groupId>org.codehaus.jackson</groupId>
    <artifactId>jackson-jaxrs</artifactId>
    <version>${jackson.version}</version>
    </dependency>

    <!-- j2ee web spec -->
    <dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>servlet-api</artifactId>
    <version>2.5</version>
    <scope>provided</scope>
    </dependency>
    <dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>jstl</artifactId>
    <version>1.1.2</version>
    </dependency>
    <dependency>
    <groupId>taglibs</groupId>
    <artifactId>standard</artifactId>
    <version>1.1.2</version>
    </dependency>
    <!-- web end -->
    <!-- security begin -->
    <dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-core</artifactId>
    <version>${spring-security.version}</version>
    </dependency>
    <dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-config</artifactId>
    <version>${spring-security.version}</version>
    </dependency>
    <dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-web</artifactId>
    <version>${spring-security.version}</version>
    </dependency>
    <dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-taglibs</artifactId>
    <version>${spring-security.version}</version>
    </dependency>

    <dependency>
    <groupId>com.octo.captcha</groupId>
    <artifactId>jcaptcha</artifactId>
    <version>1.0</version>
    </dependency>
    <!-- security end -->

    <!-- quartz -->
    <dependency>
    <groupId>org.quartz-scheduler</groupId>
    <artifactId>quartz</artifactId>
    <version>${quartz.version}</version>
    </dependency>

    <!-- logging begin-->
    <!-- slf4j -->
    <dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
    <version>${slf4j.version}</version>
    </dependency>

    <!-- slf4j-log4j绑定 -->
    <dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-log4j12</artifactId>
    <version>${slf4j.version}</version>
    </dependency>

    <!-- slf4j没有log4j的情形 -->
    <dependency>
    <groupId>commons-logging</groupId>
    <artifactId>commons-logging</artifactId>
    <version>1.1.1</version>
    </dependency>

    <dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.16</version>
    <exclusions>
    <exclusion>
    <groupId>javax.mail</groupId>
    <artifactId>mail</artifactId>
    </exclusion>
    <exclusion>
    <groupId>javax.jms</groupId>
    <artifactId>jms</artifactId>
    </exclusion>
    <exclusion>
    <groupId>com.sun.jdmk</groupId>
    <artifactId>jmxtools</artifactId>
    </exclusion>
    <exclusion>
    <groupId>com.sun.jmx</groupId>
    <artifactId>jmxri</artifactId>
    </exclusion>
    <exclusion>
    <groupId>oro</groupId>
    <artifactId>oro</artifactId>
    </exclusion>
    </exclusions>
    </dependency>
    <!-- logging end-->

    <!-- xml begin -->
    <dependency>
    <groupId>com.sun.xml.bind</groupId>
    <artifactId>jaxb-impl</artifactId>
    <version>2.2.1</version>
    </dependency>

    <dependency>
    <groupId>dom4j</groupId>
    <artifactId>dom4j</artifactId>
    <version>1.6.1</version>
    </dependency>

    <dependency>
    <groupId>jaxen</groupId>
    <artifactId>jaxen</artifactId>
    <version>1.1.1</version>
    </dependency>

    <dependency>
    <groupId>xerces</groupId>
    <artifactId>xercesImpl</artifactId>
    <version>2.9.1</version>
    </dependency>
    <!-- xml end -->

    <!-- utils begin -->
    <dependency>
    <groupId>commons-beanutils</groupId>
    <artifactId>commons-beanutils</artifactId>
    <version>1.8.3</version>
    </dependency>
    <dependency>
    <groupId>commons-lang</groupId>
    <artifactId>commons-lang</artifactId>
    <version>2.5</version>
    </dependency>
    <dependency>
    <groupId>commons-collections</groupId>
    <artifactId>commons-collections</artifactId>
    <version>3.2.1</version>
    </dependency>
    <dependency>
    <groupId>commons-codec</groupId>
    <artifactId>commons-codec</artifactId>
    <version>1.4</version>
    </dependency>
    <dependency>
    <groupId>commons-io</groupId>
    <artifactId>commons-io</artifactId>
    <version>1.4</version>
    </dependency>

    <dependency>
    <groupId>com.google.collections</groupId>
    <artifactId>google-collections</artifactId>
    <version>1.0</version>
    </dependency>

    <dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpclient</artifactId>
    <version>4.0.1</version>
    </dependency>

    <dependency>
    <groupId>ognl</groupId>
    <artifactId>ognl</artifactId>
    <version>2.7.3</version>
    <exclusions>
    <!-- use javassist.javassist instead -->
    <exclusion>
    <groupId>jboss</groupId>
    <artifactId>javassist</artifactId>
    </exclusion>
    </exclusions>
    </dependency>

    <!-- template engine -->
    <dependency>
    <groupId>org.apache.velocity</groupId>
    <artifactId>velocity</artifactId>
    <version>1.6.4</version>
    </dependency>

    <!-- cache (usually for orm) -->
    <dependency>
    <groupId>net.sf.ehcache</groupId>
    <artifactId>ehcache</artifactId>
    <version>1.6.2</version>
    </dependency>

    <dependency>
    <groupId>asm</groupId>
    <artifactId>asm</artifactId>
    <version>3.2</version>
    </dependency>
    <!-- utils end -->

    <!-- test begin -->
    <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.8.1</version>
    <scope>test</scope>
    </dependency>

    <dependency>
    <groupId>org.easymock</groupId>
    <artifactId>easymock</artifactId>
    <version>3.0</version>
    <scope>test</scope>
    </dependency>

    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-test</artifactId>
    <version>${spring.version}</version>
    <scope>test</scope>
    </dependency>

    <!-- jetty -->
    <dependency>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>jetty</artifactId>
    <version>${jetty.version}</version>
    <scope>test</scope>
    </dependency>
    <dependency>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>jsp-2.1-jetty</artifactId>
    <version>${jetty.version}</version>
    <scope>test</scope>
    </dependency>

    <!-- selenium 2.0 -->
    <dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-htmlunit-driver</artifactId>
    <version>${selenium.version}</version>
    <scope>test</scope>
    </dependency>

    <dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-firefox-driver</artifactId>
    <version>${selenium.version}</version>
    <scope>test</scope>
    </dependency>

    <dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-ie-driver</artifactId>
    <version>${selenium.version}</version>
    <scope>test</scope>
    </dependency>

    <dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-remote-client</artifactId>
    <version>${selenium.version}</version>
    <scope>test</scope>
    </dependency>

    <dependency>
    <groupId>org.dbunit</groupId>
    <artifactId>dbunit</artifactId>
    <version>2.4.7</version>
    <scope>test</scope>
    </dependency>

    <dependency>
    <groupId>com.h2database</groupId>
    <artifactId>h2</artifactId>
    <version>${h2.version}</version>
    <scope>test</scope>
    </dependency>
    <!-- test end -->

    <!-- hibernate tools -->
    <!-- newest version in jboss repository -->
    <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-tools</artifactId>
    <version>3.2.3.GA</version>
    <scope>provided</scope>
    <exclusions>
    <exclusion>
    <groupId>freemarker</groupId>
    <artifactId>freemarker</artifactId>
    </exclusion>
    </exclusions>
    </dependency>

    <!-- javascript/css compress tools -->
    <dependency>
    <groupId>com.yahoo.platform.yui</groupId>
    <artifactId>yuicompressor</artifactId>
    <version>2.4.2</version>
    <scope>provided</scope>
    </dependency>

    <dependency>
    <groupId>ant</groupId>
    <artifactId>ant</artifactId>
    <version>1.7.0</version>
    <scope>provided</scope>
    </dependency>
    </dependencies>
    </dependencyManagement>
    4.在kay/web/pom.xml的dependencies节点添加以下依赖

    <!-- spring begin -->
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    </dependency>
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-beans</artifactId>
    </dependency>
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
    </dependency>

    <!-- spring aop -->
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-aop</artifactId>
    </dependency>
    <dependency>
    <groupId>org.aspectj</groupId>
    <artifactId>aspectjweaver</artifactId>
    </dependency>
    <dependency>
    <groupId>cglib</groupId>
    <artifactId>cglib-nodep</artifactId>
    </dependency>
    <!-- spring end -->

    <!-- database access begin -->
    <!-- hibernate -->
    <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    </dependency>
    <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-annotations</artifactId>
    </dependency>
    <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-ehcache</artifactId>
    </dependency>
    <!-- newest version in jboss repository -->
    <dependency>
    <groupId>javassist</groupId>
    <artifactId>javassist</artifactId>
    </dependency>

    <!-- spring orm -->
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-orm</artifactId>
    </dependency>

    <!-- optional datasource-->
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-jdbc</artifactId>
    </dependency>

    <dependency>
    <groupId>commons-dbcp</groupId>
    <artifactId>commons-dbcp</artifactId>
    </dependency>
    <!-- database access end -->

    <!-- web begin -->
    <!-- struts2 -->
    <dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-core</artifactId>
    </dependency>
    <dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-spring-plugin</artifactId>
    </dependency>
    <dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-convention-plugin</artifactId>
    </dependency>
    <dependency>
    <groupId>org.freemarker</groupId>
    <artifactId>freemarker</artifactId>
    </dependency>

    <!-- spring web -->
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web</artifactId>
    </dependency>
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
    </dependency>

    <!-- json -->
    <dependency>
    <groupId>org.codehaus.jackson</groupId>
    <artifactId>jackson-core-asl</artifactId>
    </dependency>
    <dependency>
    <groupId>org.codehaus.jackson</groupId>
    <artifactId>jackson-mapper-asl</artifactId>
    </dependency>
    <dependency>
    <groupId>org.codehaus.jackson</groupId>
    <artifactId>jackson-jaxrs</artifactId>
    </dependency>

    <!-- j2ee web spec -->
    <dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>servlet-api</artifactId>
    <scope>provided</scope>
    </dependency>
    <dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>jstl</artifactId>
    </dependency>
    <dependency>
    <groupId>taglibs</groupId>
    <artifactId>standard</artifactId>
    </dependency>
    <!-- web end -->
    <!-- security begin -->
    <dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-core</artifactId>
    </dependency>
    <dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-config</artifactId>
    </dependency>
    <dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-web</artifactId>
    </dependency>
    <dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-taglibs</artifactId>
    </dependency>

    <dependency>
    <groupId>com.octo.captcha</groupId>
    <artifactId>jcaptcha</artifactId>
    </dependency>
    <!-- security end -->

    <!-- quartz -->
    <dependency>
    <groupId>org.quartz-scheduler</groupId>
    <artifactId>quartz</artifactId>
    </dependency>

    <!-- logging begin-->
    <!-- slf4j -->
    <dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
    </dependency>

    <!-- slf4j-log4j绑定 -->
    <dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-log4j12</artifactId>
    </dependency>

    <!-- slf4j没有log4j的情形 -->
    <dependency>
    <groupId>commons-logging</groupId>
    <artifactId>commons-logging</artifactId>
    </dependency>

    <dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    </dependency>
    <!-- logging end-->

    <!-- xml begin -->
    <dependency>
    <groupId>com.sun.xml.bind</groupId>
    <artifactId>jaxb-impl</artifactId>
    </dependency>

    <dependency>
    <groupId>dom4j</groupId>
    <artifactId>dom4j</artifactId>
    </dependency>

    <dependency>
    <groupId>jaxen</groupId>
    <artifactId>jaxen</artifactId>
    </dependency>

    <dependency>
    <groupId>xerces</groupId>
    <artifactId>xercesImpl</artifactId>
    </dependency>
    <!-- xml end -->

    <!-- utils begin -->
    <dependency>
    <groupId>commons-beanutils</groupId>
    <artifactId>commons-beanutils</artifactId>
    </dependency>
    <dependency>
    <groupId>commons-lang</groupId>
    <artifactId>commons-lang</artifactId>
    </dependency>
    <dependency>
    <groupId>commons-collections</groupId>
    <artifactId>commons-collections</artifactId>
    </dependency>
    <dependency>
    <groupId>commons-codec</groupId>
    <artifactId>commons-codec</artifactId>
    </dependency>
    <dependency>
    <groupId>commons-io</groupId>
    <artifactId>commons-io</artifactId>
    </dependency>

    <dependency>
    <groupId>com.google.collections</groupId>
    <artifactId>google-collections</artifactId>
    </dependency>

    <dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpclient</artifactId>
    </dependency>

    <dependency>
    <groupId>ognl</groupId>
    <artifactId>ognl</artifactId>
    </dependency>

    <!-- template engine -->
    <dependency>
    <groupId>org.apache.velocity</groupId>
    <artifactId>velocity</artifactId>
    </dependency>

    <!-- cache (usually for orm) -->
    <dependency>
    <groupId>net.sf.ehcache</groupId>
    <artifactId>ehcache</artifactId>
    </dependency>

    <dependency>
    <groupId>asm</groupId>
    <artifactId>asm</artifactId>
    </dependency>
    <!-- utils end -->

    <!-- test begin -->
    <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    </dependency>

    <dependency>
    <groupId>org.easymock</groupId>
    <artifactId>easymock</artifactId>
    </dependency>

    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-test</artifactId>
    </dependency>

    <!-- jetty -->
    <dependency>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>jetty</artifactId>
    </dependency>
    <dependency>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>jsp-2.1-jetty</artifactId>
    </dependency>

    <!-- selenium 2.0 -->
    <dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-htmlunit-driver</artifactId>
    </dependency>

    <dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-firefox-driver</artifactId>
    </dependency>

    <dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-ie-driver</artifactId>
    </dependency>

    <dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-remote-client</artifactId>
    </dependency>

    <dependency>
    <groupId>org.dbunit</groupId>
    <artifactId>dbunit</artifactId>
    </dependency>

    <dependency>
    <groupId>com.h2database</groupId>
    <artifactId>h2</artifactId>
    </dependency>
    <!-- test end -->

    <!-- hibernate tools -->
    <!-- newest version in jboss repository -->
    <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-tools</artifactId>
    </dependency>

    <!-- javascript/css compress tools -->
    <dependency>
    <groupId>com.yahoo.platform.yui</groupId>
    <artifactId>yuicompressor</artifactId>
    </dependency>
    5.在build/plugins节点添加eclipse插件,使得maven可以将web模块转为eclipse项目

    <!-- eclipse插件 -->
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-eclipse-plugin</artifactId>
    <configuration>
    <wtpversion>2.0</wtpversion>
    <additionalProjectnatures>
    <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
    <projectnature>org.maven.ide.eclipse.maven2Nature</projectnature>
    <projectnature>org.eclipse.jdt.core.javanature</projectnature>
    </additionalProjectnatures>
    </configuration>
    </plugin>
    6.添加jetty插件

    <plugin>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>maven-jetty-plugin</artifactId>
    <configuration>
    <scanIntervalSeconds>10</scanIntervalSeconds>
    <stopKey>foo</stopKey>
    <stopPort>9999</stopPort>
    <webAppConfig>
    <contextPath>/kay</contextPath>
    <tempDirectory>${project.build.directory}/work</tempDirectory>
    </webAppConfig>
    <connectors>
    <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
    <port>80</port>
    <maxIdleTime>60000</maxIdleTime>
    </connector>
    <!--
    <connector
    implementation="org.mortbay.jetty.ssl.SslSelectChannelConnector">
    <port>8443</port> <maxIdleTime>60000</maxIdleTime> <keystore>
    ${basedir}/src/test/jetty/server.keystore </keystore>
    <keyPassword>123456</keyPassword> </connector>
    -->
    </connectors>
    </configuration>
    <executions>
    <execution>
    <id>start-jetty</id>
    <phase>pre-integration-test</phase>
    <goals>
    <goal>run</goal>
    </goals>
    <configuration>
    <scanIntervalSeconds>0</scanIntervalSeconds>
    <daemon>true</daemon>
    </configuration>
    </execution>
    <execution>
    <id>stop-jetty</id>
    <phase>post-integration-test</phase>
    <goals>
    <goal>stop</goal>
    </goals>
    </execution>
    </executions>
    </plugin>
    7.未完待续。。。。。。

  • 相关阅读:
    A+B for Input-Output Practice (VIII)
    A+B for Input-Output Practice (VI)
    A+B for Input-Output Practice (VII)
    A+B for Input-Output Practice (IV)
    1.1.4 A+B for Input-Output Practice (V)
    1.1.3 A+B for Input-Output Practice (III)
    基础练习 龟兔赛跑预测
    基础练习 回形取数
    Python实用黑科技——以某个字段进行分组
    Python黑科技神奇去除马赛克
  • 原文地址:https://www.cnblogs.com/adaikiss/p/1806024.html
Copyright © 2011-2022 走看看