日期:2014-05-16 浏览次数:20447 次
<dependency> <groupId>hsqldb</groupId> <artifactId>hsqldb</artifactId> <version>1.8.0.7</version> <scope>test</scope> </dependency>
?
@Before public void prepareData() throws ServiceException { if($needPrePareData){ executeSqlFile("init_data.sql"); } } private void executeSqlFile(String fileName){ try{ File refFile = new File(ClassLoader.getSystemResource(fileName).toURI()); SqlFile sqlFile = new SqlFile(refFile,false,null); sqlFile.execute(dataSource.getConnection(), true); }catch(Exception e){ System.out.println("exception when prepare Data "); e.printStackTrace(); } }
db.dialect=org.hibernate.dialect.HSQLDialect db.driver=org.hsqldb.jdbcDriver db.url=jdbc:hsqldb:mem:DBName db.username=sa db.passwd=
<build> <plugins> <!-- other plugins ... --> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>hibernate3-maven-plugin</artifactId> <version>2.2</version> <executions> <execution> <phase>process-classes</phase> <goals> <goal>hbm2ddl</goal> </goals> </execution> </executions> <configuration> <components> <component> <name>hbm2ddl</name> <implementation>jpaconfiguration</implementation> </component> </components> <componentProperties> <persistenceunit>Default</persistenceunit> <outputfilename>schema.ddl</outputfilename> <drop>false</drop> <create>true</create> <export>false</export> <format>true</format> </componentProperties> </configuration> </plugin>