Spring 控制器don'中的弹簧注释;不行?@Secure和@Async都不起作用
我使用SpringRoo生成我的项目。我不知道这两件事是否相关,但在控制器中,@Async或@Secure注释都不起作用。 对于@Secure: 我在applicationContext-security.xml中添加了Spring 控制器don'中的弹簧注释;不行?@Secure和@Async都不起作用,spring,spring-security,spring-roo,Spring,Spring Security,Spring Roo,我使用SpringRoo生成我的项目。我不知道这两件事是否相关,但在控制器中,@Async或@Secure注释都不起作用。 对于@Secure: 我在applicationContext-security.xml中添加了标记,并修改了pom.xml以满足依赖性 <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-
标记,并修改了pom.xml以满足依赖性
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-aspects</artifactId>
<version>3.0.5.RELEASE</version>
</dependency>
在controller.java中:
@Async
private void justWait20seconds() {
try {
Thread.sleep(20000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
我希望这个方法不会阻止main方法,但是它没有。这两个标签都在我的UserController.java中,我不知道它们是否链接。有人能帮忙吗?听起来您不明白Spring MVC应用程序中的Spring上下文是如何组织的,并且正在将注释处理指令添加到错误的上下文中。阅读SpringMVC中的Spring上下文。您可以在以下位置找到我的另一个SO答案:我遇到了同样的问题,安全注释在Roo项目的jspx中工作,但在控制器中不工作。我的修复方法是将以下内容添加到webmvc-config.xml中:
<security:global-method-security secured-annotations="enabled" />
(将此添加到applicationContext-security.xml对我不起作用)
然后我在pom.xml中为cglib添加了依赖项:
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.2</version>
</dependency>
cglib
cglib
2.2
这些注释是否在@Service
bean中工作?或者,另一方面,尝试移动Hello Tomasz,*-servlet.xml
的作用是什么?在我的项目中,我没有这样的配置文件,该文件中有什么?
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.2</version>
</dependency>