我在每个文件夹中复制了persistence.xml,但仍然显示无法找到文件persistence.xml。请帮忙。
错误:
[INFO] using jpaconfiguration task.
19:19:52,652 INFO org.hibernate.cfg.annotations.Version - Hibernate Annotations 3.4.0.GA
19:19:52,657 INFO org.hibernate.cfg.Environment - Hibernate 3.3.1.GA
19:19:52,659 INFO org.hibernate.cfg.Environment - hibernate.properties not found
19:19:52,661 INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist
19:19:52,663 INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
19:19:52,691 INFO org.hibernate.annotations.common.Version - Hibernate Commons Annotations 3.1.0.GA
19:19:52,693 INFO org.hibernate.ejb.Version - Hibernate EntityManager 3.4.0.GA
19:19:52,702 INFO org.hibernate.ejb.Ejb3Configuration - Could not find any META-INF/persistence.xml file in the classpath
[ERROR] Persistence unit not found: 'myapp'.
的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>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.3</version>
</dependency>
<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>com.springsource.repository.bundles.release</id>
<name>SpringSource Enterprise Bundle Repository - SpringSource Bundle Releases</name>
<url>http://repository.springsource.com/maven/bundles/release</url>
</repository>
<repository>
<id>com.springsource.repository.bundles.external</id>
<name>SpringSource Enterprise Bundle Repository - External Bundle Releases</name>
<url>http://repository.springsource.com/maven/bundles/external</url>
</repository>
<repository>
<id>maven2</id>
<url>http://repo1.maven.org/maven2</url>
</repository>
<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>
<executions>
<execution>
<id>generate-xml-files</id>
<phase>generate-resources</phase>
<goals>
<goal>hbm2hbmxml</goal>
<goal>hbm2cfgxml</goal>
</goals>
</execution>
<execution>
<id>generate-entities</id>
<phase>generate-sources</phase>
<goals>
<goal>hbm2java</goal>
</goals>
</execution>
</executions>
<configuration>
<components>
<component>
<name>hbm2hbmxml</name>
<implementation>jdbcconfiguration</implementation>
<outputDirectory>src/main/resources</outputDirectory>
</component>
<component>
<name>hbm2cfgxml</name>
<implementation>jdbcconfiguration</implementation>
<outputDirectory>src/main/resources</outputDirectory>
</component>
<component>
<name>hbm2java</name>
<implementation>configuration</implementation>
<outputDirectory>src/main/java</outputDirectory>
</component>
</components>
<componentProperties>
<implementation>jpaconfiguration</implementation>
<persistenceunit>myapp</persistenceunit>
<propertyfile>src/main/resources/database.properties</propertyfile>
<jdk5>true</jdk5>
<ejb3>true</ejb3>
<packagename>com.adept.reverse</packagename>
<format>true</format>
<haltonerror>true</haltonerror>
</componentProperties>
</configuration>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<type>jar</type>
<version>5.1.23</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
答案 0 :(得分:3)
src/main/resources/META-INF/persistence.xml