提交 3d5799dc 编写于 作者: C Calvin

数据库初始化改为用maven, quickstart.bat不再依赖ant,另在初始化数据前,会等待H2启动完毕。

上级 72965c2a
......@@ -4,17 +4,12 @@
TODO部分:
1.主要改动
*
--清理相关类
2.次要改动
* 初始化数据不要再依赖Ant
全部完成
---------------------------------------------------------------------------------
已完成部分:
1. 主要改动
* DAO框架用Spring Data JPA(Hibernate的JPA实现)代替Hibernate原生API + DIY BaseDao基类
* DAO框架用Spring Data JPA + Hibernate的JPA实现代替Hibernate原生API + DIY BaseDao基类
* DAO框架增加MyBatis的使用,与Hibernate在不同的场景各展所长
* MVC框架从Struts2转为Spring MVC3
* 安全框架从SpringSecurity转为Apache Shiro
......@@ -22,8 +17,8 @@ TODO部分:
* CSS框架从YUI转为Blueprint
* Spring引入Profile概念统一测试、生产環境的配置
* 演示Hibernate Validator
* 升級Jackson1.9 演示,包括可擴展的對象, 對象循環引用,局部更新,自定义类型的持久化,自定义Naming策略,已存在對象等新特性.
* 添加各种常用Utility的Demo, 升级Guava和Commons-Lang3.0.
* 升級Jackson1.9 演示,包括可擴展的對象, 對象循環引用,局部更新,自定义类型的持久化,自定义Naming策略,已存在對象等新特性.
* 升级Selenium2.0演示,融合Selenium 1.0与2.0的API
* Mock框架从EasyMock+JMock换成Mockito + PowerMock
* SpringSide Modules的重构
......@@ -34,7 +29,7 @@ TODO部分:
* 升级JodaTime2.0版演示
* 使用log4jdbc打印SQL及执行时间
* 演示RESTful库Jersey的Multi-Part客户端与服务端
* Form内容对齐从Table改为Label+CSS
* Form对齐从Table改为Label+CSS
* 删除已过期演示: CXF的ws-security和ws附件协议,Flash Chart, 驗證碼, JMX客户端
* 依赖包版本的升级
-- Spring 3.0.4->3.1.1, CXF 2.2.10->2.5.2, Jersey 1.3->1.11, Activemq 5.4.0->5.5.1, Jquery 1.4->1.7.1, Ehcache 1.6—>2.5.1
......@@ -45,6 +40,7 @@ TODO部分:
3. 其他非代码改动
* 使用Maven FailSafe插件分开单元测试和集成测试
* 数据库初始化从ant改为用maven,消除quick-start对ant的依赖
* cxf wsdl2java从ant改为用maven plugin
* hibernate代码生成从ant改为用Eclipse插件
......@@ -56,7 +52,8 @@ TODO部分:
1.主要改动
* 升级Hibernate 4.0
* Schedule演示升级,升级Quartz2.x,Spring Schedule Executor配置升级
* Search Form与分页
* Search与分页演示
2.次要改动
* 包括Guava的Cache Builder做的简单缓存
......@@ -64,10 +61,11 @@ TODO部分:
* Review perf4j的使用
* Jersey的Jackson JSON绑定看有没有简化,并升级其他用法。
* 升级Jquery-validation用法?? JQuery flash效果
* Ehcache2.x新功能演示
* JPA2.0特征
* Shiro的方法级权限控制, Test Helper, enable/diable用户抛出用户已锁定的异常.
* Hash与加密要加入salt
* UT只初始化一次數據
* UT更智能的初始化數據,dirty data 的标签??
* 用JUnit自带的Catetory的演示,Harmset演示
* Selenium使用自带的Wait类, 检查新版API变化
* 更深入演示PowerMock
......
<?xml version="1.0" encoding="UTF-8"?>
<project name="mini-service" default="init-db" xmlns:artifact="antlib:org.apache.maven.artifact.ant" basedir="../../">
<artifact:dependencies pathId="project.lib">
<pom file="pom.xml" />
</artifact:dependencies>
<property file="src/main/resources/application.properties" />
<property name="sql.type" value="h2" />
<property name="dbunit.datatype" value="org.dbunit.ext.h2.H2DataTypeFactory" />
<property name="sql.dir" value="src/main/resources/sql/${sql.type}" />
<property name="dbunit.data.dir" value="src/test/resources/data" />
<taskdef name="dbunit" classname="org.dbunit.ant.DbUnitTask" classpathref="project.lib" />
<target name="init-db">
<sql driver="${jdbc.driver}" url="${jdbc.url}" userid="${jdbc.username}" password="${jdbc.password}" src="${sql.dir}/schema.sql" onerror="continue">
<classpath refid="project.lib" />
</sql>
<dbunit driver="${jdbc.driver}" url="${jdbc.url}" userid="${jdbc.username}" password="${jdbc.password}">
<dbconfig>
<property name="datatypeFactory" value="${dbunit.datatype}" />
</dbconfig>
<classpath refid="project.lib" />
<operation type="CLEAN_INSERT" src="${dbunit.data.dir}/sample-data.xml" format="flat" transaction="true"/>
</dbunit>
</target>
<target name="exp-db">
<dbunit driver="${jdbc.driver}" url="${jdbc.url}" userid="${jdbc.username}" password="${jdbc.password}">
<dbconfig>
<property name="datatypeFactory" value="${dbunit.datatype}" />
</dbconfig>
<classpath refid="project.lib" />
<export dest="${dbunit.data.dir}/export-data.xml" format="flat" />
</dbunit>
</target>
</project>
@echo off
echo [INFO] Export data to src/main/resources/data/export-data.xml by dbunit.
cd %~dp0
call ant exp-db
pause
\ No newline at end of file
@echo off
echo [INFO] Create schema by sql, and import default data from src/test/resources/data/sample-data.xml by dbunit.
cd %~dp0
call ant init-db
pause
\ No newline at end of file
@echo off
echo [INFO] Re-create the schema and provision the sample data.
cd %~dp0
cd ..
set MAVEN_OPTS=%MAVEN_OPTS%
call mvn antrun:run -Prefreshdb
cd bin
pause
\ No newline at end of file
......@@ -265,4 +265,47 @@
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>refreshdb</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<configuration>
<target>
<property file="src/main/resources/application.properties" />
<property name="sql.type" value="h2" />
<property name="dbunit.datatype" value="org.dbunit.ext.h2.H2DataTypeFactory" />
<taskdef name="dbunit" classname="org.dbunit.ant.DbUnitTask" classpathref="maven.test.classpath" />
<echo>Waiting for the h2 server start...</echo>
<waitfor maxwait="500" maxwaitunit="second">
<and>
<socket server="localhost" port="9092"/>
</and>
</waitfor>
<echo>The h2 server started.</echo>
<sql driver="${jdbc.driver}" url="${jdbc.url}" userid="${jdbc.username}" password="${jdbc.password}" src="src/main/resources/sql/${sql.type}/schema.sql" onerror="continue">
<classpath refid="maven.test.classpath" />
</sql>
<dbunit driver="${jdbc.driver}" url="${jdbc.url}" userid="${jdbc.username}" password="${jdbc.password}">
<dbconfig>
<property name="datatypeFactory" value="${dbunit.datatype}" />
</dbconfig>
<classpath refid="maven.test.classpath" />
<operation type="CLEAN_INSERT" src="src/test/resources/data/sample-data.xml" format="flat" transaction="true"/>
</dbunit>
</target>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project name="mini-web" default="init-db" xmlns:artifact="antlib:org.apache.maven.artifact.ant" basedir="../../">
<artifact:dependencies pathId="project.lib">
<pom file="pom.xml" />
</artifact:dependencies>
<property file="src/main/resources/application.properties" />
<property name="sql.type" value="h2" />
<property name="dbunit.datatype" value="org.dbunit.ext.h2.H2DataTypeFactory" />
<!--
<property name="sql.type" value="oracle" />
<property name="dbunit.datatype" value="org.dbunit.ext.oracle.Oracle10DataTypeFactory" />
-->
<!--
<property name="sql.type" value="mysql" />
<property name="dbunit.datatype" value="org.dbunit.ext.mysql.MySqlDataTypeFactory" />
-->
<property name="sql.dir" value="src/main/resources/sql/${sql.type}" />
<property name="dbunit.data.dir" value="src/test/resources/data" />
<taskdef name="dbunit" classname="org.dbunit.ant.DbUnitTask" classpathref="project.lib" />
<target name="init-db">
<sql driver="${jdbc.driver}" url="${jdbc.url}" userid="${jdbc.username}" password="${jdbc.password}" src="${sql.dir}/schema.sql" onerror="continue">
<classpath refid="project.lib" />
</sql>
<dbunit driver="${jdbc.driver}" url="${jdbc.url}" userid="${jdbc.username}" password="${jdbc.password}">
<dbconfig>
<property name="datatypeFactory" value="${dbunit.datatype}" />
</dbconfig>
<classpath refid="project.lib" />
<operation type="CLEAN_INSERT" src="${dbunit.data.dir}/sample-data.xml" format="flat" transaction="true"/>
</dbunit>
</target>
<target name="exp-db">
<dbunit driver="${jdbc.driver}" url="${jdbc.url}" userid="${jdbc.username}" password="${jdbc.password}">
<dbconfig>
<property name="datatypeFactory" value="${dbunit.datatype}" />
</dbconfig>
<classpath refid="project.lib" />
<export dest="${dbunit.data.dir}/export-data.xml" format="flat" />
</dbunit>
</target>
<target name="convert.mysql.to.h2" description="convert mysql sql to h2 for testing">
<copy todir="src/main/resources/sql/h2" overwrite="true">
<fileset dir="src/main/resources/sql/mysql">
<include name="**/*.sql" />
</fileset>
</copy>
<replace dir="src/main/resources/sql/h2" includes="**/*.sql" token="ENGINE=InnoDB" value="" />
<replace dir="src/main/resources/sql/h2" includes="**/*.sql" token="ENGINE=MyISAM" value="" />
<replace dir="src/main/resources/sql/h2" includes="**/*.sql" token="bigint not null auto_increment" value="bigint generated by default as identity" />
<replace dir="src/main/resources/sql/h2" includes="**/*.sql" token="drop foreign key" value="drop constraint" />
<replaceregexp byline="true">
<regexp pattern="INDEX (.*)" />
<substitution expression=" " />
<fileset dir="src/main/resources/sql/h2">
<include name="*.sql" />
</fileset>
</replaceregexp>
</target>
</project>
@echo off
echo [INFO] Convert production sql to H2 sql for testing.
cd %~dp0
call ant convert.mysql.to.h2
pause
\ No newline at end of file
@echo off
echo [INFO] Export data to src/main/resources/data/export-data.xml by dbunit.
cd %~dp0
call ant exp-db
pause
\ No newline at end of file
@echo off
echo [INFO] Create schema by sql, and import default data from src/test/resources/data/sample-data.xml by dbunit.
cd %~dp0
call ant init-db
pause
\ No newline at end of file
@echo off
echo [INFO] Re-create the schema and provision the sample data.
cd %~dp0
cd ..
set MAVEN_OPTS=%MAVEN_OPTS%
call mvn antrun:run -Prefreshdb
cd bin
pause
\ No newline at end of file
......@@ -288,4 +288,47 @@
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>refreshdb</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<configuration>
<target>
<property file="src/main/resources/application.properties" />
<property name="sql.type" value="h2" />
<property name="dbunit.datatype" value="org.dbunit.ext.h2.H2DataTypeFactory" />
<taskdef name="dbunit" classname="org.dbunit.ant.DbUnitTask" classpathref="maven.test.classpath" />
<echo>Waiting for the h2 server start...</echo>
<waitfor maxwait="500" maxwaitunit="second">
<and>
<socket server="localhost" port="9092"/>
</and>
</waitfor>
<echo>The h2 server started.</echo>
<sql driver="${jdbc.driver}" url="${jdbc.url}" userid="${jdbc.username}" password="${jdbc.password}" src="src/main/resources/sql/${sql.type}/schema.sql" onerror="continue">
<classpath refid="maven.test.classpath" />
</sql>
<dbunit driver="${jdbc.driver}" url="${jdbc.url}" userid="${jdbc.username}" password="${jdbc.password}">
<dbconfig>
<property name="datatypeFactory" value="${dbunit.datatype}" />
</dbconfig>
<classpath refid="maven.test.classpath" />
<operation type="CLEAN_INSERT" src="src/test/resources/data/sample-data.xml" format="flat" transaction="true"/>
</dbunit>
</target>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project name="mini-service" default="init-db" xmlns:artifact="antlib:org.apache.maven.artifact.ant" basedir="../../">
<artifact:dependencies pathId="project.lib">
<pom file="pom.xml" />
</artifact:dependencies>
<property file="src/main/resources/application.properties" />
<property name="sql.type" value="h2" />
<property name="dbunit.datatype" value="org.dbunit.ext.h2.H2DataTypeFactory" />
<property name="sql.dir" value="src/main/resources/sql/${sql.type}" />
<property name="dbunit.data.dir" value="src/test/resources/data" />
<taskdef name="dbunit" classname="org.dbunit.ant.DbUnitTask" classpathref="project.lib" />
<target name="init-db">
<sql driver="${jdbc.driver}" url="${jdbc.url}" userid="${jdbc.username}" password="${jdbc.password}" src="${sql.dir}/schema.sql" onerror="continue">
<classpath refid="project.lib" />
</sql>
<sql driver="${quartz.jdbc.driver}" url="${quartz.jdbc.url}" userid="${quartz.jdbc.username}" password="${quartz.jdbc.password}" src="${sql.dir}/quartz.sql" onerror="continue">
<classpath refid="project.lib" />
</sql>
<dbunit driver="${jdbc.driver}" url="${jdbc.url}" userid="${jdbc.username}" password="${jdbc.password}">
<dbconfig>
<property name="datatypeFactory" value="${dbunit.datatype}" />
</dbconfig>
<classpath refid="project.lib" />
<operation type="CLEAN_INSERT" src="${dbunit.data.dir}/sample-data.xml" format="flat" transaction="true"/>
</dbunit>
</target>
<target name="exp-db">
<dbunit driver="${jdbc.driver}" url="${jdbc.url}" userid="${jdbc.username}" password="${jdbc.password}">
<dbconfig>
<property name="datatypeFactory" value="${dbunit.datatype}" />
</dbconfig>
<classpath refid="project.lib" />
<export dest="${dbunit.data.dir}/export-data.xml" format="flat" />
</dbunit>
</target>
</project>
@echo off
echo [INFO] Export data to src/main/resources/data/export-data.xml by dbunit.
cd %~dp0
call ant exp-db
pause
\ No newline at end of file
@echo off
echo [INFO] Create schema by sql, and import default data from src/test/resources/data/sample-data.xml by dbunit.
cd %~dp0
call ant init-db
pause
\ No newline at end of file
@echo off
echo [INFO] Re-create the schema and provision the sample data.
cd %~dp0
cd ..
set MAVEN_OPTS=%MAVEN_OPTS%
call mvn antrun:run -Prefreshdb
cd bin
pause
\ No newline at end of file
......@@ -455,6 +455,47 @@
</build>
<profiles>
<profile>
<id>refreshdb</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<configuration>
<target>
<property file="src/main/resources/application.properties" />
<property name="sql.type" value="h2" />
<property name="dbunit.datatype" value="org.dbunit.ext.h2.H2DataTypeFactory" />
<taskdef name="dbunit" classname="org.dbunit.ant.DbUnitTask" classpathref="maven.test.classpath" />
<echo>Waiting for the h2 server start...</echo>
<waitfor maxwait="500" maxwaitunit="second">
<and>
<socket server="localhost" port="9092"/>
</and>
</waitfor>
<echo>The h2 server started.</echo>
<sql driver="${jdbc.driver}" url="${jdbc.url}" userid="${jdbc.username}" password="${jdbc.password}" src="src/main/resources/sql/${sql.type}/schema.sql" onerror="continue">
<classpath refid="maven.test.classpath" />
</sql>
<dbunit driver="${jdbc.driver}" url="${jdbc.url}" userid="${jdbc.username}" password="${jdbc.password}">
<dbconfig>
<property name="datatypeFactory" value="${dbunit.datatype}" />
</dbconfig>
<classpath refid="maven.test.classpath" />
<operation type="CLEAN_INSERT" src="src/test/resources/data/sample-data.xml" format="flat" transaction="true"/>
</dbunit>
</target>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<!-- 使用Assembly打包jsw+jetty+webapp可运行包的profile -->
<profile>
<id>package-bin</id>
......
@echo off
echo [Pre-Requirement] Makesure install JDK 6.0+ and set the JAVA_HOME.
echo [Pre-Requirement] Makesure install Maven 3.0+, Ant 1.8+ and set the PATH.
echo [Pre-Requirement] Makesure download the maven-ant-tasks.jar and put it in Ant's lib dir.
echo [Pre-Requirement] Makesure install Maven 3.0+
set MVN=mvn
set ANT=ant
set MAVEN_OPTS=%MAVEN_OPTS% -XX:MaxPermSize=128m
echo [Step 1] Install all springside modules to local maven repository, and generate eclipse files to all projects.
......@@ -20,26 +18,26 @@ cd ..\..\
echo [Step 3] Mini-Service:init database data and start jetty.
cd examples\mini-service
call %ANT% -f bin/db/build.xml init-db
call %MVN% antrun:run -Prefreshdb
if errorlevel 1 goto error
start "Mini-Service" %MVN% jetty:run -Djetty.port=8082
start "Mini-Service" %MVN% clean jetty:run -Djetty.port=8082
cd ..\..\
echo [Step 4] Mini-Web:init database data and start jetty.
cd examples\mini-web
call %ANT% -f bin/db/build.xml init-db
call %MVN% antrun:run -Prefreshdb
if errorlevel 1 goto error
start "Mini-Web" %MVN% jetty:run -Djetty.port=8081
cd ..\..\
echo [Step 5] Showcase:init database data and start jetty.
cd examples\showcase
call %ANT% -f bin/db/build.xml init-db
call %MVN% antrun:run -Prefreshdb
if errorlevel 1 goto error
start "Showcase" %MVN% jetty:run
cd ..\..\
echo [INFO] SpringSide4.0 Quick Start finish.
echo [INFO] SpringSide4.0 Quick Start finished.
echo [INFO] Access below demo sites:
echo [INFO] http://localhost:8082/mini-service
echo [INFO] http://localhost:8081/mini-web
......@@ -47,6 +45,6 @@ echo [INFO] http://localhost:8080/showcase
goto end
:error
echo Error Happen!!! Please check the Pre-Requirement.
echo Error Happen!!!
:end
pause
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册