maven 之 hibernate 文件生成

1. 编写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/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion> 
	<groupId>my.test</groupId>
	<artifactId>myHiberante</artifactId>
	<version>1.0</version>  
	<name>myHiberante</name>
	<url>http://maven.apache.org</url>

	<properties> 
	</properties> 
	<build> 
		<plugins>  
		    <plugin>
					<groupId>org.codehaus.mojo</groupId>
					<artifactId>hibernate3-maven-plugin</artifactId>
					<version>2.2</version>
					<configuration>
						<components>
							<component>
								<name>hbm2java</name>
								<outputDirectory>hibernate/java</outputDirectory>
								<implementation>jdbcconfiguration</implementation>
							</component>
							<component>
								<name>hbm2hbmxml</name>
								<outputDirectory>hibernate/hbm</outputDirectory>
								<implementation>jdbcconfiguration</implementation>
							</component>
						</components>
						<componentProperties>
							<revengfile>model.rev.xml</revengfile>
							<propertyfile>hibernate.properties</propertyfile>
							<jdk5>true</jdk5>
							<ejb3>false</ejb3>
						</componentProperties>
					</configuration>
					<dependencies>
						<dependency>
							<groupId>mysql</groupId>
							<artifactId>mysql-connector-java</artifactId>
							<version>5.0.8</version>
						</dependency>
						<dependency>
							<groupId>cglib</groupId>
							<artifactId>cglib-nodep</artifactId>
							<version>2.1_3</version>
						</dependency>
							<dependency>
							<groupId>mysql</groupId>
							<artifactId>mysql-connector-java</artifactId>
							<version>5.0.8</version>
						</dependency>
						<dependency>
							<groupId>log4j</groupId>
							<artifactId>log4j</artifactId>
							<version>1.2.14-ext</version>
						</dependency>
					</dependencies>
					<executions>
						<execution>
							<phase>compile</phase>
							<goals>
								<goal>hbm2java</goal>
								<goal>hbm2hbmxml</goal>
							</goals>
						</execution>
					</executions> 
				</plugin>			
		</plugins>
	</build> 
</project>

 2. 在本目录下新建以下两个文件:

a. model.rev.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering SYSTEM "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd">
<hibernate-reverse-engineering>

	<table-filter match-name=".*" package="your.package.here" />


</hibernate-reverse-engineering>

b.hibernate.properties

hibernate.dialect = org.hibernate.dialect.MySQLInnoDBDialect
hibernate.connection.driver_class = com.mysql.jdbc.Driver
hibernate.connection.url = jdbc:mysql://localhost:3306/contact
hibernate.connection.username = root
hibernate.connection.password= 1
hibernate.default_schema = contact

3. 运行maven 命令

mvn hibernate3:hbm2java

4. 得到的生成文件目录

maven 之 hibernate 文件生成

6. 完毕

 

你可能感兴趣的:(maven,hbm2java,hbm2hbmxml)