0

我试图设置一个在 jboss 容器中运行的 jsf、hibernate 项目。我的 pom 文件应该引入我的依赖项并让我访问我的 bean 类中的休眠注释。然而,休眠 jar 文件被拉入我的目标文件夹,并且来自这些 jar 的注释在我的类文件夹中对我不可用,即使我尝试导入 org.hibernate。在我用 maven 将它们拉入后,我应该手动添加这些罐子,我想这应该自动完成吗?

下面是我的pom文件。

<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>net.bluedash</groupId>
<artifactId>jsfdemo</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>jsfdemo Maven Webapp</name>
<url>http://maven.apache.org</url>

<repositories>
    <repository>
        <id>jvnet-nexus-releases</id>
        <name>jvnet-nexus-releases</name>
        <url>https://maven.java.net/content/repositories/releases/</url>
    </repository>
    <repository>
        <id>jboss-public-repository-group</id>
        <name>JBoss Public Repository Group</name>
        <url>http://repository.jboss.org/nexus/content/groups/public/</url>
        <layout>default</layout>
        <releases>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
        </releases>
        <snapshots>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
        </snapshots>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>jboss-public-repository-group</id>
        <name>JBoss Public Repository Group</name>
        <url>http://repository.jboss.org/nexus/content/groups/public/</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
</pluginRepositories>

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>javax.faces</groupId>
        <artifactId>jsf-api</artifactId>
        <version>2.1</version>
        <scope>provided</scope>
    </dependency>
    <!-- MySQL database driver -->
<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.9</version>
</dependency>

<!-- Hibernate framework -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.1.9.Final</version>

<!-- Hibernate library dependecy start -->
<dependency>
    <groupId>dom4j</groupId>
    <artifactId>dom4j</artifactId>
    <version>1.6.1</version>
</dependency>

<dependency>
    <groupId>commons-logging</groupId>
    <artifactId>commons-logging</artifactId>
    <version>1.1.1</version>
</dependency>

<dependency>
    <groupId>commons-collections</groupId>
    <artifactId>commons-collections</artifactId>
    <version>3.2.1</version>
</dependency>

<dependency>
    <groupId>cglib</groupId>
    <artifactId>cglib</artifactId>
    <version>2.2</version>
</dependency>
<!-- Hibernate library dependecy end -->

<dependency>
    <groupId>javax.transaction</groupId>
    <artifactId>jta</artifactId>
    <version>1.1</version>
</dependency>
</dependencies>


<build>
    <!-- This lets maven know where the hibernate cfg file is -->
    <resources>
        <resource>
            <filtering>true</filtering>
            <directory>resources.hibernate</directory>
        </resource>
    </resources>
    <plugins>
        <plugin>
            <groupId>org.jboss.as.plugins</groupId>
            <artifactId>jboss-as-maven-plugin</artifactId>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>deploy</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>

    <finalName>jsfdemo</finalName>
</build>

4

2 回答 2

0

请加:

<dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>${hibernate.version}</version>                      
</dependency>

其中:
hibernate.version = 3.4.0.GA 用于 JPA1
4.1.x.final 用于 JPA2

hibernate-entitymanager 将下载 hibernate-annotations 和 hibernate-jpa-2.0-api。

于 2013-02-04T07:39:59.293 回答
0

Inside eclipse, once I downloaded the maven extensions, I was able to right click on my project->select Maven->update project. This cause my project to build itself and produced the project as it should be.

于 2013-02-11T16:37:26.210 回答