解决IDEA2020.1程序运行必须构选Delegate IDE build/run actions to Maven

每次运行代码都要将代码交给maven托管,运行Test方法都需要Build整个项目,搞得心态都崩了。

解决方案:

首先注释setting文件中的localRepository标签

 然后在IDEA中手动配置maven仓库地址,使用默认仓库和本地仓库都是可以的。再运行程序,瞬间清爽了许多。

 

 

### 如何解决 Java 项目中 `org.springframework.beans.factory.annotation` 包不存在的问题 当遇到 `org.springframework.beans.factory.annotation` 包无法找到的情况时,通常是因为项目的依赖项未被正确解析或导入。以下是几种可能的原因及解决方案: #### 1. 检查 Maven 依赖配置 确保在 `pom.xml` 文件中有正确的 Spring Framework 和 Spring Boot 依赖项。 ```xml <dependencies> <!-- Spring Boot Starter Dependency --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <!-- Additional dependency for spring-context which includes the annotation package --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${spring.version}</version> </dependency> <!-- Ensure you have this specific module that contains @Autowired and other annotations --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>${spring.version}</version> </dependency> </dependencies> ``` 上述代码片段展示了如何通过添加必要的依赖来引入所需的包[^1]。 #### 2. 更新 IDEA 设置以更好地处理Maven建过程 如果确认 pom 中已包含所需依赖但仍存在问题,则可能是由于 IDE 缓存或其他因素引起的。此时应考虑调整 IntelliJ IDEA 的设置: - 勾 "Delegate IDE build/run actions to Maven" 项可以让IDEA 使用 Maven 执行编译和运行命令而不是内置工具,这有助于确保所有外部库都能按预期加载。 此操作可以通过进入 File -> Settings (Ctrl+Alt+S), 然后导航到 Build, Execution, Deployment -> Build Tools -> Maven -> Runner 完成设置[^3]. #### 3. 清理并重新安装本地仓库中的缓存文件 有时候本地 Maven 库可能会损坏或者不完整,尝试清理后再下载一次最新的版本也可能解决问题. 可以在终端输入如下命令完成该操作: ```bash mvn clean install -U ``` 这条指令会强制更新所有的快照(SNAPSHOT)依赖,并清除旧版的 jar 文件再重新获取最新的一份副本[^2].
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值