当前位置: 首页 > 知识库问答 >
问题:

javax。坚持不懈唯一约束。name()Ljava/lang/String

夔宏深
2023-03-14

创建在类路径资源[ApplicationContext.xml]中定义的名为“sessionFactory”的bean时出错:调用init方法失败;嵌套异常为java。lang.NoSuchMethodError:javax。坚持不懈唯一约束。name()Ljava/lang/String;

这有什么不对吗?

我用的是

<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>org.aaaedu.aaaspeak3</groupId>
<artifactId>aaaspeak3</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>aaaspeak3 Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>

    <javax.version>6.0</javax.version>
    <javax.servlet.version>1.2</javax.servlet.version>
    <junit.version>4.8.2</junit.version>
    <log4j.version>1.2.16</log4j.version>
    <org.aspectj.version>1.6.2</org.aspectj.version>
    <net.sf.ehcache.version>2.3.2</net.sf.ehcache.version>
    <org.slf4j.version>1.6.1</org.slf4j.version>
    <mysql.jdbc.version>5.1.15</mysql.jdbc.version>
    <org.hibernate.entitymanager.version>3.6.10.Final</org.hibernate.entitymanager.version>
    <org.springframework.version>3.0.5.RELEASE</org.springframework.version>
    <com.jolbox.bonecp.version>0.7.1.RELEASE</com.jolbox.bonecp.version>
    <org.codehaus.jackson.version>1.7.4</org.codehaus.jackson.version>
    <commons.pool.version>20030821.192746</commons.pool.version>
    <commons.dbcp.version>20030821.193421</commons.dbcp.version>
    <org.jfreechart.version>1.0.14</org.jfreechart.version>
</properties>

<repositories>
    <repository>
        <id>sonatype-snapshots</id>
        <name>Sonatype snapshot repository</name>
        <url>http://oss.sonatype.org/content/repositories/snapshots</url>
    </repository>
    <repository>
        <id>java.net2</id>
        <name>Repository hosting the jee6 artifacts</name>
        <url>http://download.java.net/maven/2</url>
    </repository>
    <repository>
        <id>JBoss</id>
        <name>The "public-jboss" repository group provides a combined view all JBoss community project artifacts</name>
        <layout>default</layout>
        <url>http://repository.jboss.org/nexus/content/groups/public-jboss</url>
    </repository>
    <repository>
        <releases>
            <enabled>true</enabled>
        </releases>
        <id>bonecp-repo</id>
        <name>BoneCP Repository</name>
        <url>http://jolbox.com/bonecp/downloads/maven</url>
    </repository>
    <repository>
        <id>CodeHaus-Jackson</id>
        <name>Json CodeHaus Jackson</name>
        <url>http://repository.codehaus.org/org/codehaus/jackson/</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
    <groupId>javax.persistence</groupId>
    <artifactId>persistence-api</artifactId>
    <version>1.0.2</version>
    <type>jar</type>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>servlet-api</artifactId>
    <version>2.5</version>
    <type>jar</type>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>javax.validation</groupId>
    <artifactId>validation-api</artifactId>
    <version>1.0.0.GA</version>
    <type>jar</type>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>javax.transaction</groupId>
    <artifactId>jta</artifactId>
    <version>1.1</version>
    <type>jar</type>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>jstl</artifactId>
    <version>1.2</version>
    <type>jar</type>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>javax.el</groupId>
    <artifactId>el-api</artifactId>
    <version>2.2</version>
    <type>jar</type>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>jsp-api</artifactId>
    <version>2.0</version>
    <type>jar</type>
    <scope>provided</scope>
</dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-jdk14</artifactId>
        <version>${org.slf4j.version}</version>
    </dependency>

     <!--  <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-web-api</artifactId>
        <version>6.0</version>
        <scope>provided</scope>
    </dependency> -->

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>${junit.version}</version>
        <scope>test</scope>
    </dependency>

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



    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
        <version>4.3.0.Final</version>
    </dependency>

    <dependency>
        <groupId>net.sf.ehcache</groupId>
        <artifactId>ehcache-core</artifactId>
        <version>${net.sf.ehcache.version}</version>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>${javax.servlet.version}</version>
        <scope>runtime</scope>
    </dependency>

    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>${log4j.version}</version>
    </dependency>

    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjtools</artifactId>
        <version>${org.aspectj.version}</version>
    </dependency>

    <!-- JDBC -->
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>${mysql.jdbc.version}</version>
    </dependency>

    <!-- BoneCP -->
    <dependency>
        <groupId>com.jolbox</groupId>
        <artifactId>bonecp</artifactId>
        <version>${com.jolbox.bonecp.version}</version>
    </dependency>

    <dependency>
        <groupId>com.jolbox</groupId>
        <artifactId>bonecp-provider</artifactId>
        <version>${com.jolbox.bonecp.version}</version>
    </dependency>

    <dependency>
        <groupId>com.jolbox</groupId>
        <artifactId>bonecp-spring</artifactId>
        <version>${com.jolbox.bonecp.version}</version>
    </dependency>

    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-core-asl</artifactId>
        <version>${org.codehaus.jackson.version}</version>
    </dependency>

    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-core-lgpl</artifactId>
        <version>${org.codehaus.jackson.version}</version>
    </dependency>

    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-mapper-asl</artifactId>
        <version>${org.codehaus.jackson.version}</version>
    </dependency>

    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-mapper-lgpl</artifactId>
        <version>${org.codehaus.jackson.version}</version>
    </dependency>

    <!-- spring framework -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-aop</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-asm</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-beans</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-expression</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-orm</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-tx</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <version>${org.springframework.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>commons-pool</groupId>
        <artifactId>commons-pool</artifactId>
        <version>${commons.pool.version}</version>
    </dependency>
    <dependency>
        <groupId>commons-dbcp</groupId>
        <artifactId>commons-dbcp</artifactId>
        <version>${commons.dbcp.version}</version>
    </dependency>
    <dependency>
        <groupId>org.jfree</groupId>
        <artifactId>jfreechart</artifactId>
        <version>${org.jfreechart.version}</version>
    </dependency>
</dependencies>
<build>
    <finalName>aaaspeak3</finalName>
</build>

有人告诉我这是“hibernate-jpa-2.0-api-1.0.0.jar”和我others.how做的冲突吗?谢谢!

共有1个答案

司徒耀
2023-03-14

此依赖关系适用于JPA 1:

<dependencies>
    <dependency>
    <groupId>javax.persistence</groupId>
    <artifactId>persistence-api</artifactId>
    <version>1.0.2</version>
    <type>jar</type>
    <scope>provided</scope>
</dependency>

正如您所看到的,JPA 1中的UniqueConstraint没有名称属性,但在JPA 2中它是存在的。您确实参考了“hibernate-jpa-2.0-api-1.0.0.jar”,这是由hibernate提供的jpa2.0api。但是你的pom。xml不包括这样的文件。您可以通过在pom中添加以下内容来包括该版本(或实际上从未包含的版本):

<dependency>
    <groupId>org.hibernate.javax.persistence</groupId>
    <artifactId>hibernate-jpa-2.0-api</artifactId>
    <version>1.0.1.Final</version>
</dependency>

此外,您应该删除对JPA 1 API的依赖关系。

 类似资料:
  • 我有一个Play框架应用程序,我使用的是Hibernate 4.2。5.最终版本(通过Maven依赖关系管理器检索)。我决定升级到Hibernate4.3。0.最后,成功重新编译我的应用程序并运行它。 我得到了下面的例外,并没有能够找出原因。我降级回到4.2.5,这个问题没有发生。然后,我尝试在4.2.5之后的每个最终版本中升级Hibernate。也就是说,我从4.2.5。最终到4.2.6。最后,

  • 我正在开发Spring Boot应用程序,在启动服务器时遇到了这个错误。我不确定是否错误地定义了任何注释或缺少任何依赖项。任何帮助都将不胜感激。 主要类: UserService类: UserDAO类: @repository公共类UserDAO实现IUserDAO{ Build.gradle: 错误消息: 我看到了所有相关的答案,并尝试实现这些建议,如添加依赖项、在主类中添加符号等。但它显示了相

  • 除了这个错误之外,我似乎在依赖项方面有很多问题,我正在试图修复它们,但我对Maven来说是一个完全的新手: 罐子未加载。参见Servlet规范2.3,第9.7.2节。违规类:javax/el/expression.class> 罐子未加载。参见Servlet规范2.3,第9.7.2节。违规类:javax/el/expression.class> null null null null null 我

  • 我有一个问题,这似乎是非常类似于如何创建一个Jandex索引在Quarkus的类在一个外部模块,我仔细地按照所有建议的步骤(jandex maven插件,空beans.xml,索引其他依赖)。 与上述问题的一个明显区别是,quarkus在我的案例中没有找到第三方类,所以我尝试“索引其他依赖项”。然而,javax。坚持不懈AttributeConverter是maven模块javax的一部分。持久性

  • 我在启动我的web应用程序时遇到了这个错误,我真的不知道问题出在哪里,全速: 组织。springframework。豆。工厂UnsatisfiedPendencyException:创建名为“usuarioController”的bean时出错,该名称在文件[C:\Users\Carlos\eclipsejee workspace.metadata.plugins\org.eclipse.wst.

  • 线程“main”java.lang.nosuchmethoderror中出现异常:com/myapp/client.cyphercbc(ljava/lang/string;)ljava/lang/string; 但它在另一个本地环境中运行良好。到目前为止我的代码在下面;