Created
September 4, 2012 02:11
-
-
Save eric2323223/3615753 to your computer and use it in GitHub Desktop.
Sample spring embedded database configuration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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:jdbc="http://www.springframework.org/schema/jdbc" | |
xmlns:tx="http://www.springframework.org/schema/tx" | |
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd | |
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd | |
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd | |
"> | |
<jdbc:embedded-database id="dataSource" type="HSQL"> | |
<jdbc:script location="schema.xml"/> | |
<jdbc:script location="test-data.xml"/> | |
</jdbc:embedded-database> | |
<bean id="entityManagerFactory" | |
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> | |
<property name="persistenceUnitName" value="testingSetup"/> | |
<property name="dataSource" ref="dataSource"/> | |
<property name="jpaVendorAdapter"> | |
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> | |
<!-- Create the database, please --> | |
<property name="generateDdl" value="true"/> | |
</bean> | |
</property> | |
</bean> | |
<!--<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">--> | |
<!--<property name="entityManagerFactory" ref="entityManagerFactory"/>--> | |
<!--</bean>--> | |
<!--<tx:annotation-driven/>--> | |
</beans> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<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/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>com.eric.mvnlab</groupId> | |
<artifactId>tiny</artifactId> | |
<version>1.0</version> | |
<dependencies> | |
<dependency> | |
<groupId>org.springframework</groupId> | |
<artifactId>spring-context</artifactId> | |
<version>${mvn.spring.version}</version> | |
</dependency> | |
<dependency> | |
<groupId>org.springframework</groupId> | |
<artifactId>spring-tx</artifactId> | |
<version>${mvn.spring.version}</version> | |
</dependency> | |
<dependency> | |
<groupId>log4j</groupId> | |
<artifactId>log4j</artifactId> | |
<version>1.2.14</version> | |
<scope>runtime</scope> | |
</dependency> | |
<dependency> | |
<groupId>org.springframework.data</groupId> | |
<artifactId>spring-data-jpa</artifactId> | |
<version>1.0.3.RELEASE</version> | |
</dependency> | |
<dependency> | |
<groupId>junit</groupId> | |
<artifactId>junit</artifactId> | |
<version>4.10</version> | |
<scope>test</scope> | |
</dependency> | |
<dependency> | |
<groupId>org.easytesting</groupId> | |
<artifactId>fest-assert</artifactId> | |
<version>1.4</version> | |
<scope>test</scope> | |
</dependency> | |
<dependency> | |
<groupId>org.springframework</groupId> | |
<artifactId>spring-test</artifactId> | |
<version>${mvn.spring.version}</version> | |
<scope>test</scope> | |
</dependency> | |
<dependency> <!-- needed to get AOPs around the test cases --> | |
<groupId>cglib</groupId> | |
<artifactId>cglib-nodep</artifactId> | |
<version>2.2.2</version> | |
<scope>test</scope> | |
</dependency> | |
<dependency> | |
<groupId>org.hsqldb</groupId> | |
<artifactId>hsqldb</artifactId> | |
<version>2.2.8</version> | |
<scope>test</scope> | |
</dependency> | |
<dependency> | |
<groupId>org.slf4j</groupId> | |
<artifactId>slf4j-log4j12</artifactId> | |
<version>1.6.4</version> | |
<scope>runtime</scope> | |
</dependency> | |
<dependency> | |
<groupId>javassist</groupId> | |
<artifactId>javassist</artifactId> | |
<version>3.4.GA</version> | |
</dependency> | |
<dependency> | |
<groupId>org.aspectj</groupId> | |
<artifactId>aspectjrt</artifactId> | |
<version>1.5.4</version> | |
</dependency> | |
<dependency> | |
<groupId>org.hibernate</groupId> | |
<artifactId>hibernate-entitymanager</artifactId> | |
<version>3.5.1-Final</version> | |
</dependency> | |
<dependency> | |
<groupId>org.mockito</groupId> | |
<artifactId>mockito-core</artifactId> | |
<version>1.9.0</version> | |
<scope>test</scope> | |
</dependency> | |
<dependency> | |
<groupId>pl.pragmatists</groupId> | |
<artifactId>JUnitParams</artifactId> | |
<version>0.3.7</version> | |
<scope>test</scope> | |
</dependency> | |
</dependencies> | |
<properties> | |
<mvn.spring.version>3.0.6.RELEASE</mvn.spring.version> | |
<mvn.project.build.sourceEncoding>UTF-8</mvn.project.build.sourceEncoding> | |
<mvn.var1>Hello</mvn.var1> | |
<mvn.main.class>com.eric.mvnlab.Main</mvn.main.class> | |
<!-- log4j --> | |
<mvn.log4j.rootCategory>WARN</mvn.log4j.rootCategory> | |
<mvn.log4j.category.org.springframework.beans.factory>WARN</mvn.log4j.category.org.springframework.beans.factory> | |
</properties> | |
<build> | |
<resources> | |
<resource> | |
<directory>src/main/resources</directory> | |
<filtering>true</filtering> | |
</resource> | |
<resource> | |
<directory>src/test/resources</directory> | |
<filtering>true</filtering> | |
</resource> | |
</resources> | |
<pluginManagement> | |
<plugins> | |
<plugin> | |
<artifactId>maven-compiler-plugin</artifactId> | |
<version>2.3.2</version> | |
</plugin> | |
<plugin> | |
<artifactId>maven-ear-plugin</artifactId> | |
<version>2.4.2</version> | |
</plugin> | |
<plugin> | |
<artifactId>maven-war-plugin</artifactId> | |
<version>2.1</version> | |
</plugin> | |
<plugin> | |
<artifactId>maven-resources-plugin</artifactId> | |
<version>2.4.3</version> | |
</plugin> | |
</plugins> | |
</pluginManagement> | |
<plugins> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-compiler-plugin</artifactId> | |
<version>2.3.2</version> | |
<configuration> | |
<source>1.6</source> | |
<target>1.6</target> | |
<encoding>${mvn.project.build.sourceEncoding}</encoding> | |
</configuration> | |
</plugin> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-resources-plugin</artifactId> | |
<version>2.4.3</version> | |
<configuration> | |
<encoding>${mvn.project.build.sourceEncoding}</encoding> | |
</configuration> | |
</plugin> | |
<plugin> | |
<groupId>org.codehaus.mojo</groupId> | |
<artifactId>exec-maven-plugin</artifactId> | |
<version>1.1</version> | |
<configuration> | |
<mainClass>${mvn.main.class}</mainClass> | |
</configuration> | |
</plugin> | |
<plugin> | |
<artifactId>maven-assembly-plugin</artifactId> | |
<version>2.2</version> | |
<configuration> | |
<descriptorRefs> | |
<descriptorRef>jar-with-dependencies</descriptorRef> | |
</descriptorRefs> | |
<archive> | |
<manifest> | |
<mainClass>${mvn.main.class}</mainClass> | |
</manifest> | |
</archive> | |
</configuration> | |
</plugin> | |
</plugins> | |
</build> | |
<profiles> | |
<profile> | |
<id>dist</id> | |
<build> | |
<plugins> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-dependency-plugin</artifactId> | |
<executions> | |
<execution> | |
<id>copy-dependencies</id> | |
<phase>package</phase> | |
<goals> | |
<goal>copy-dependencies</goal> | |
</goals> | |
<configuration> | |
<outputDirectory>target/dist/lib</outputDirectory> | |
<includeScope>runtime</includeScope> | |
</configuration> | |
</execution> | |
</executions> | |
</plugin> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-antrun-plugin</artifactId> | |
<version>1.6</version> | |
<executions> | |
<execution> | |
<phase>package</phase> | |
<configuration> | |
<target> | |
<echo message="Start ant task copy ${project.build.directory}${file.separator}${project.build.finalName}.jar" /> | |
<copy todir="${project.build.directory}${file.separator}/dist"> | |
<fileset dir="${project.build.directory}"> | |
<include name="${project.build.finalName}.jar" /> | |
</fileset> | |
</copy> | |
</target> | |
</configuration> | |
<goals> | |
<goal>run</goal> | |
</goals> | |
</execution> | |
</executions> | |
</plugin> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-jar-plugin</artifactId> | |
<configuration> | |
<archive> | |
<manifest> | |
<classpathPrefix>lib/</classpathPrefix> | |
<addClasspath>true</addClasspath> | |
<mainClass>${mvn.main.class}</mainClass> | |
</manifest> | |
</archive> | |
</configuration> | |
</plugin> | |
</plugins> | |
</build> | |
</profile> | |
<profile> | |
<id>test-integrate</id> | |
<build> | |
<plugins> | |
<plugin> | |
<groupId>org.codehaus.mojo</groupId> | |
<artifactId>build-helper-maven-plugin</artifactId> | |
<version>1.5</version> | |
<executions> | |
<execution> | |
<id>add-test-source</id> | |
<phase>generate-sources</phase> | |
<goals> | |
<goal>add-test-source</goal> | |
</goals> | |
<configuration> | |
<sources> | |
<source>src/test-integrate/java</source> | |
</sources> | |
</configuration> | |
</execution> | |
<execution> | |
<id>add-resource</id> | |
<phase>generate-resources</phase> | |
<goals> | |
<goal>add-test-resource</goal> | |
</goals> | |
<configuration> | |
<resources> | |
<resource> | |
<directory>src/test-integrate/resources</directory> | |
</resource> | |
</resources> | |
</configuration> | |
</execution> | |
</executions> | |
</plugin> | |
</plugins> | |
</build> | |
<dependencies> | |
<dependency> | |
<groupId>org.springframework</groupId> | |
<artifactId>spring-test</artifactId> | |
<version>${mvn.spring.version}</version> | |
<scope>test</scope> | |
</dependency> | |
</dependencies> | |
</profile> | |
<profile> | |
<!-- | |
mvn package -P dist,win32-native-exec | |
--> | |
<id>win32-native-exec</id> | |
<build> | |
<plugins> | |
<plugin> | |
<groupId>com.akathist.maven.plugins.launch4j</groupId> | |
<artifactId>launch4j-maven-plugin</artifactId> | |
<executions> | |
<execution> | |
<id>l4j-clui</id> | |
<phase>package</phase> | |
<goals> | |
<goal>launch4j</goal> | |
</goals> | |
<configuration> | |
<headerType>console</headerType> | |
<outfile>target/${project.artifactId}.exe</outfile> | |
<jar>target/${project.artifactId}-${project.version}.jar</jar> | |
<errTitle>${project.artifactId} error</errTitle> | |
<icon>icon.ico</icon> | |
<classPath> | |
<mainClass>${mvn.main.class}</mainClass> | |
<addDependencies>true</addDependencies> | |
<preCp>anything</preCp> | |
</classPath> | |
<jre> | |
<minVersion>1.6.0</minVersion> | |
</jre> | |
<versionInfo> | |
<fileVersion>${project.version}.0</fileVersion> | |
<txtFileVersion>${project.version}</txtFileVersion> | |
<fileDescription>${product.description}</fileDescription> | |
<copyright>Copyright © 2011 ${product.company}</copyright> | |
<productVersion>${project.version}.0</productVersion> | |
<txtProductVersion>${project.version}</txtProductVersion> | |
<companyName>${product.company}</companyName> | |
<productName>${product.title}</productName> | |
<internalName>${project.artifactId}</internalName> | |
<originalFilename>${project.artifactId}.exe</originalFilename> | |
</versionInfo> | |
</configuration> | |
</execution> | |
</executions> | |
</plugin> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-antrun-plugin</artifactId> | |
<version>1.6</version> | |
<executions> | |
<execution> | |
<phase>package</phase> | |
<configuration> | |
<target> | |
<copy todir="${project.build.directory}${file.separator}/dist"> | |
<fileset dir="${project.build.directory}"> | |
<include name="${project.build.finalName}.jar" /> | |
<include name="*.exe" /> | |
</fileset> | |
</copy> | |
</target> | |
</configuration> | |
<goals> | |
<goal>run</goal> | |
</goals> | |
</execution> | |
</executions> | |
</plugin> | |
</plugins> | |
</build> | |
<repositories> | |
<repository> | |
<id>akathist-repository</id> | |
<name>Akathist Repository</name> | |
<url>http://www.9stmaryrd.com/maven</url> | |
</repository> | |
</repositories> | |
<pluginRepositories> | |
<pluginRepository> | |
<id>Akathist Repository</id> | |
<url>http://www.9stmaryrd.com/maven</url> | |
</pluginRepository> | |
</pluginRepositories> | |
<properties> | |
<product.company>Product company</product.company> | |
<product.title>Product title</product.title> | |
<product.description>Product description></product.description> | |
<!-- console or gui --> | |
<headerType>console</headerType> | |
</properties> | |
</profile> | |
</profiles> | |
</project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
drop table Persons if exists; | |
CREATE TABLE Persons | |
( | |
Id_P int, | |
LastName varchar(255), | |
FirstName varchar(255), | |
Address varchar(255), | |
City varchar(255) | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INSERT INTO Persons values (1, 'eric', 'peng', 'xaut', 'xian'); | |
INSERT INTO Persons values (2, 'mark', 'ma', 'xjtu', 'xian'); | |
INSERT INTO Persons values (3, 'dong', 'xu', 'xjtu', 'xian'); | |
INSERT INTO Persons values (4, 'tim', 'liu', 'xjtu', 'xian'); | |
INSERT INTO Persons values (5, 'york', 'li', 'xjtu', 'xian'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment