gpt4 book ai didi

java - EnableTransactionManagement 无法解析为类型

转载 作者:行者123 更新时间:2023-11-30 07:00:48 24 4
gpt4 key购买 nike

package com.shaun.spring.config;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@Configuration
@ComponentScan("com.shaun.spring")
@EnableTransactionManagement
public class ApplicationContextConfig {

// @Bean configurations go here...

}

我对@EnableTransactionManagement 有疑问发生的以下错误是:EnableTransactionManagement 无法解析为类型。

我的 pom.xml 中有以下依赖项:

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>4.1.6.RELEASE</version>
</dependency>

我也尝试过使用以下导入:

import org.springframework.transaction.annotation.EnableTransactionManagement;

这给了我以下错误:

The import org.springframework.transaction.annotation.EnableTransactionManagement cannot be resolved

最佳答案

您缺少对象关系映射的 spring-orm 依赖项。

只需将它导入到你的pom文件中

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>4.1.6.RELEASE</version>
</dependency>

关于java - EnableTransactionManagement 无法解析为类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30260510/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com