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. 得到的生成文件目录



6. 完毕

 

转载于:https://my.oschina.net/frankies/blog/69124

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值