包 javax.annotation.security 不存在

package javax.annotation.security does not exist

我正在尝试从头开始一个基于 Jersey/1.7 的项目(而不是复制现有项目并在上面添加新代码,这是我的客户通常所做的)以便学习事情怎么样。我还处于早期阶段,试图处理一个简单的 HTTP 请求:

package com.example.foo.view.rest;

import javax.ws.rs.Path;
import javax.annotation.security.RolesAllowed; // package javax.annotation.security does not exist

@Path("user")
@RolesAllowed("valid-users") // cannot find symbol
public class UserService extends BaseService {
    public UserService() {
        super();
    }
}

我从另一个项目复制了这些文件:

asm-3.1.jar
jackson-core-asl-1.9.2.jar
jackson-jaxrs-1.9.2.jar
jackson-mapper-asl-1.9.2.jar
jackson-xc-1.9.2.jar
jersey-client-1.17.jar
jersey-core-1.17.jar
jersey-json-1.17.jar
jersey-multipart-1.17.jar
jersey-server-1.17.jar
jersey-servlet-1.17.jar
jettison-1.1.jar
jsr311-api-1.1.1.jar

项目身份验证适用于 Oracle SSO(Oracle 身份目录)。

我唯一能找到的 javax.annotation.security.RolesAllowed 是一个接口,而且我在我的代码库中肯定看不到任何实际实现。事实上,整个 javax.annotation.security 包都不见了。我什至不知道什么图书馆应该提供它。

我会很感激任何提示,无论它看起来多么明显。

javax.annotation 是 java 的一部分,但不直接包含在 jre 中。 它不包括在运动衫中。 您必须将 this jar 添加到您的项目才能正常工作。