有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java hibernate。cfg。即使在运行mvn hibernate3:hbm2cfgxml时,也没有创建xml

当我运行mvn hibernate3:hbm2cfgxml时,它不会生成hibernate。cfg。xml文件。 不过,它会生成POJO和DAO,但不会生成hibernate。cfg。xml文件

下面是我的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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.myhadoop.app</groupId>
<artifactId>my-app-hadoop</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>my-app-hadoop</name>
<url>http://maven.apache.org</url>

<dependencies>
<dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <version>3.8.1</version>
  <scope>test</scope>
</dependency>

<dependency>
    <groupId>org.apache.hadoop</groupId>
    <artifactId>hadoop-core</artifactId>
    <version>1.0.3</version>
</dependency>

<dependency>
    <groupId>org.hibernate </groupId>
    <artifactId>hibernate-core</artifactId>
    <version>4.1.6.Final</version>
</dependency>

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>servlet-api</artifactId>
    <version>3.0-alpha-1</version>
</dependency>

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-simple</artifactId>
    <version>1.6.6</version>
</dependency>

<dependency>
    <groupId>javassist</groupId>
    <artifactId>javassist</artifactId>
    <version>3.12.1.GA </version>
</dependency>
</dependencies>
<repositories>
<repository>
    <id>jBoss-Repository</id>
    <url>https://repository.jboss.org/nexus/content/groups/public/</url>
    <releases>
       <enabled>true</enabled>
    </releases>
    <snapshots>
      <enabled>false</enabled>
    </snapshots>        
 </repository>
 <repository>
    <id>mirrors.ibiblio</id>
    <url>http://mirrors.ibiblio.org/maven/mule/dependencies/maven2/</url>
    <releases>
       <enabled>true</enabled>
    </releases>
    <snapshots>
      <enabled>false</enabled>
    </snapshots>        
 </repository>
 </repositories>
 <build>
<plugins>
    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>hibernate3-maven-plugin</artifactId>
        <version>2.2</version>
        <configuration>
            <components>
                <component>
                    <name>hbm2ddl</name>
                         <implementation>jdbcconfiguration</implementation>
                </component>
                <component>
                    <name>hbm2hbmxml</name>
                    <implementation>jdbcconfiguration</implementation>
                    <outputDirectory>src/main/java/org/dbmxml</outputDirectory>
                </component>
                <component>
                    <name>hbm2dao</name>
                    <implementation>jdbcconfiguration</implementation>
                    <outputDirectory>src/main/java</outputDirectory>
                </component>
                <component>
                    <name>hbm2java</name>
                    <implementation>jdbcconfiguration</implementation>
                    <outputDirectory>src/main/java</outputDirectory>
                </component>

                <component>
                    <name>hbm2doc</name>
                    <implementation>jdbcconfiguration</implementation>
                    <outputDirectory>src/hbm2doc</outputDirectory>
                </component>

                <component>
                    <name>hbm2ddl</name>
                    <implementation>jdbcconfiguration</implementation>
                    <outputDirectory>src/hbm2ddl</outputDirectory>
                </component>
            </components>

            <componentProperties>
                <drop>true</drop>
                <packagename>org.hbm2dao</packagename>
                <configurationfile>/src/main/resources/hibernate.cfg.xml</configurationfile>
                <propertyFile>/src/main/resources/database.properties</propertyFile>
            </componentProperties>
        </configuration>
        <dependencies>
            <dependency>
                <groupId>com.oracle</groupId>
                <artifactId>ojdbc</artifactId>
                <version>6</version>
                <scope>system</scope>
                <systemPath>D:/apps/oracle11g/product/11.2.0/dbhome_1/jdbc/lib/ojdbc6.jar</systemPath>
        </dependency>
    </dependencies>
  </plugin>
</plugins>

pom中需要添加的内容。xml,以便生成hibernate。cfg。xml文件


共 (2) 个答案

  1. # 2 楼答案

    基于documentation您需要创建一个如下所示的零件:

    <component>
      <name>hbm2cfgxml</name>
      <implementation>...</implementation>
      ...
    </component>