缺少工件 javax.transaction:jta:jar:1.0.1B (问题不同,您可能会看到分辨率不同)

2022-01-16 00:00:00 transactions spring java Hibernate struts2

我正在尝试使用示例来学习 Hibernate-Spring-Struts Struts 2 + Spring + Hibernate 集成示例.

I am trying to learn Hibernate-Spring-Struts using the example Struts 2 + Spring + Hibernate integration example.

但在创建 pom.xml 后出现此错误:

But after creating the pom.xml getting this error :

Missing artifact javax.transaction:jta:jar:1.0.1B

我仅在创建 pom.xml 文件方面取得了进展,并进行了更改以包含最新的库.

I made a progress only up to creating the pom.xml file and made the changes to include most recent libraries.

这是我的 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>S3HMaven</groupId>
<artifactId>S3HMaven</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>S3HMaven</name>
<url>http://maven.apache.org</url>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.11</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>javax.transaction</groupId>
        <artifactId>jta</artifactId>
        <version>1.0.1B</version>
    </dependency>

    <!-- Struts 2 -->
    <dependency>
        <groupId>org.apache.struts</groupId>
        <artifactId>struts2-core</artifactId>
        <version>2.1.8</version>
    </dependency>

    <!-- Struts 2 + Spring plugins -->
    <dependency>
        <groupId>org.apache.struts</groupId>
        <artifactId>struts2-spring-plugin</artifactId>
        <version>2.3.15.2</version>
    </dependency>

    <!-- MySQL database driver -->
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.26</version>
    </dependency>

    <!-- Spring framework -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring</artifactId>
        <version>2.5.6</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>2.5.6</version>
    </dependency>

    <!-- Hibernate core -->
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate</artifactId>
        <version>3.2.7.ga</version>
    </dependency>

    <!-- Hibernate core library dependency 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 core library dependency end -->

    <!-- Hibernate query library dependency start -->
    <dependency>
        <groupId>antlr</groupId>
        <artifactId>antlr</artifactId>
        <version>2.7.7</version>
    </dependency>
    <!-- Hibernate query library dependency end -->

</dependencies>
</project>

我尝试了对 javax.transation 的依赖和不依赖.没有区别.谁能告诉我我做错了什么?我应该怎么做才能摆脱它?

I tried with and without dependency for javax.transation. Did not make difference. Can any one tell me what am I doing wrong ? What should I do to get rid of it?

推荐答案

pom.xml 中的错误是因为你弄乱了不同版本的 Struts 核心和插件.

The error in your pom.xml because you mess up different versions of Struts core and plugins.

改变

<dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-core</artifactId>
    <version>2.3.15.2</version>
</dependency>

我不知道您为什么需要 JTA 1.0.1B,但您可以将休眠更改为 3.3.2(至少,不会让人头疼)

I don't know why do you need JTA 1.0.1B but you could change hibernate to 3.3.2 (at least, without headaches)

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate</artifactId>
    <version>3.3.2.ga</version>
</dependency>

它具有 JTA 1.1 的推荐依赖项.

it has a recommended dependency for JTA 1.1.

pom.xml 创建一个新项目,然后向其中添加源文件.

Create a new project from pom.xml then add source files to it.

相关文章