这个问题在这里已有答案:
当我导入以下包时
import javax.annotation.PostConstruct; import javax.annotation.PreDestroy;
我得到了以下resulat - 无法解析导入javax.annotation.PostConstruct
如果您使用的是spring-boot及以下依赖项,那么它应该从父启动器自动添加 javax.annotation .
javax.annotation
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency>
对于非spring spring启动数据,jpa在pom.xml中添加以下依赖项
<dependency> <groupId>javax.annotation</groupId> <artifactId>javax.annotation-api</artifactId> <version>1.3.2</version> </dependency>
1 回答
如果您使用的是spring-boot及以下依赖项,那么它应该从父启动器自动添加
javax.annotation
.对于非spring spring启动数据,jpa在pom.xml中添加以下依赖项