문제점 : 12 : 03 : 10,126 ERROR org.hibernate.tool.hbm2ddl.SchemaExport - 스키마 내보내기에 실패 함 org.hibernate.HibernateException : JDBC 드라이버 클래스 찾을 수 없습니다 : com.mysql.jdbc.Driverhibernate3-maven : 부모 프로젝트에서 컴파일 할 때 하위 프로젝트에서 JDBC 드라이버를 찾을 수 없다.
프로젝트가 ParentProject와 ChildModule로 나뉘어 있습니다. ChildModule의 pom.xml을 모두 컴파일하려고하면 maven이 성공적으로 데이터베이스에 연결되어 테이블을 만듭니다. 그러나 ParentProject에서 컴파일 할 때 위에서 언급 한 오류가 발생했습니다 (hbm2ddl 실행 중). 어떤 아이디어가 문제일까요?
ParentProject의 pom.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>
부모의 플러그인은 자식이 가지고있는 mysql-connector-java에 의존하지 않습니다. 그것을 추가하려고 했습니까? –
예, 그게 문제를 해결했습니다! 당신의 도움을 주셔서 대단히 감사합니다! – Ramps
내 의견을 답으로 게시 했으므로 이제 귀하의 의견을 수락 할 수 있습니다. –