2023-08-31 11:30:31 +08:00
|
|
|
|
---
|
|
|
|
|
title: Resource注解无法导入依赖使用
|
|
|
|
|
date: 2022-03-15 00:15:53.726
|
|
|
|
|
updated: 2022-09-05 00:15:53.726
|
|
|
|
|
url: https://hhdxw.top/archives/40
|
|
|
|
|
categories:
|
|
|
|
|
- JAVA EE
|
|
|
|
|
tags:
|
|
|
|
|
- JAVA EE
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
最近在学习Spring的过程中遇到了一个棘手的问题:使用Resource注解时报错了。
|
|
|
|
|
|
2023-08-31 12:43:36 +08:00
|
|
|
|
![image-20220315214739187](https://lsky.hhdxw.top/imghub/img/image-20220315214739187.png)
|
2023-08-31 11:30:31 +08:00
|
|
|
|
|
|
|
|
|
当时上面的**@Resource**爆红,忘了截图
|
|
|
|
|
|
|
|
|
|
问题出现了,那么怎么解决呢。在百度上找到答案说:这是因为没有导入tomcat的包,tomcat里面默认继承了这个包,只要在**pom.xml**增加这个包的依赖,问题就解决了
|
|
|
|
|
|
|
|
|
|
```java
|
|
|
|
|
<dependency>
|
|
|
|
|
<groupId>javax.annotation</groupId>
|
|
|
|
|
<artifactId>jsr250-api</artifactId>
|
|
|
|
|
<version>1.0</version>
|
|
|
|
|
</dependency>
|
|
|
|
|
```
|
|
|
|
|
|
2023-08-31 12:43:36 +08:00
|
|
|
|
![image-20220315215743445](https://lsky.hhdxw.top/imghub/img/image-20220315215743445.png)
|
2023-08-31 11:30:31 +08:00
|
|
|
|
|
|
|
|
|
但是我用了这个方法没有用,依旧爆红,后来我换了**JDK**从16,17,1.6,1.8,在最后**JDK9**能用了
|