javahibernatemavenhbm2java

hibernate.cfg.xml is not getting created even when i run mvn hibernate3:hbm2cfgxml


When I run mvn hibernate3:hbm2cfgxml it does not generate hibernate.cfg.xml file. However it generates pojos and daos but does not generate hibernate.cfg.xml file.

Following is my 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>

What needs to be added in pom.xml so that I can generate hibernate.cfg.xml file.


Solution

  • Based on the documentation you need to create a part like the following:

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