English 中文(简体)
hibernate3-maven: JDBC 家长项目汇编过程中没有发现的司机
原标题:hibernate3-maven: JDBC Driver not found in child project when compiling from parent project

Problem: 12:03:10,126 ERROR org.hibernate.tool.hbm2ddl.SchemaExport - schema export unsuccessful org.hibernate.HibernateException: JDBC Driver class not found: com.mysql.jdbc.Driver

我有一个项目,分为单元:家长项目和儿童模块。 当我试图汇编儿童单元的om子时,所有东西都会奏效。 然而,在从父母项目一进行汇编时,上述错误(同时执行 h2dl)。 问题是什么想法?

这里是我的om。

父母项目编号:xml:

<project ... >
<build>
        <plugins>

            <plugin>
                <!-- JDK version used to compile project -->
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.0.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>hibernate3-maven-plugin</artifactId>
                <version>2.2</version>
            </plugin>

        </plugins>
    </build>

    <repositories>
        <repository>
            <id>JBOSS</id>
            <name>JBoss Repository</name>
            <url>http://repository.jboss.org/maven2/</url>
        </repository>
        <repository>
            <id>Codehaus Snapshots</id>
            <url>http://snapshots.repository.codehaus.org/</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
            <releases>
                <enabled>false</enabled>
            </releases>
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>Codehaus Snapshots</id>
            <url>http://snapshots.repository.codehaus.org/</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
            <releases>
                <enabled>true</enabled>
            </releases>
        </pluginRepository>
    </pluginRepositories>

    <dependencyManagement>
        <dependencies>
        ...
        </dependencies>
    </dependencyManagement>

    <modules>
        <module>../ChildModule</module>
    </modules>  
</project>

ChildModule pom.xml:

<project ... >

    <parent>
        <groupId>com.somepackage</groupId>
        <artifactId>ChildModule</artifactId>
        <version>0.1</version>
        <relativePath>../ParentProject/pom.xml</relativePath>
    </parent>

    ...

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.1</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>hibernate3-maven-plugin</artifactId>                
                <executions>

                    <execution>
                        <id>generate-entities</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>hbm2java</goal>
                        </goals>
                        <configuration>
                            <components>
                                <component>
                                    <name>hbm2java</name>
                                    <implementation>configuration</implementation>
                                    <outputDirectory>${generated-source-dir}</outputDirectory>
                                </component>
                            </components>
                            <componentProperties>                               
                                <configurationFile>src/main/resources/hibernate.cfg.xml</configurationFile>
                                <jdk5>true</jdk5>
                            </componentProperties>
                        </configuration>
                    </execution>

                    <execution>
                        <id>generate-schema</id>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>hbm2ddl</goal>
                        </goals>

                        <configuration>
                            <componentProperties>
                                <outputfilename>schema.ddl</outputfilename>
                                <drop>true</drop>
                                <ejb3>false</ejb3>
                            </componentProperties>
                        </configuration>

                    </execution>

                </executions>               
                <dependencies>
                    <dependency>
                        <groupId>mysql</groupId>
                        <artifactId>mysql-connector-java</artifactId>
                        <version>5.1.17</version>
                    </dependency>
                    <dependency>
                        <groupId>cglib</groupId>
                        <artifactId>cglib-nodep</artifactId>
                        <version>2.2.2</version>
                    </dependency>
                </dependencies>
            </plugin>

        </plugins>
    </build>


    <dependencies>

    ...

    </dependencies>

    <properties>
        <generated-source-dir>generated-sources/hibernate3</generated-source-dir>
        <generated-resource-dir>generated-resources/hibernate3</generated-resource-dir>
    </properties>

</project>
最佳回答

孩子们的母子gin子有以下几条 depend子: 我建议把这种依赖性添加到(或甚至转移)。

问题回答

暂无回答




相关问题
Derby gets stuck closing?

I ve got unit tests (in maven) that use derby. At the end of the test run, there is a very long pause, with these log messages before the pause. INFO: Closing Hibernate SessionFactory Nov 16, 2009 8:...

Execute goal on parent after children complete

I have a multi-module maven project (several levels of nesting). Normally, when I execute a maven build (like mvn install or whatever), maven will run all the goals for the parent project before ...

Including dependencies in a jar with Maven

Is there a way to force maven(2.0.9) to include all the dependencies in a single jar file? I have a project the builds into a single jar file. I want the classes from dependencies to be copied into ...

Java Equivalent of distcc

Distcc makes it easy to distribute a C or C++ compile job across a number of machines, and is a godsend for working with large, frequently-built codebases. An increasing number of our large projects ...

Maven Assembly Problem

I have a maven multiple-module project, which is giving me headaches in the assembly:assembly phase. I have a module which has an assembly defined in it which works fine when I invoke mvn assembly:...

热门标签