小编Jon*_*gel的帖子

Spring Expression Language和Spring Security 3:在@PreAuthorize中访问bean引用

我正在尝试在@PreAuthorize注释中访问bean引用,如下所示:

@PreAuthorize("@testBean.getTestValue()")
public String testSpEL() {
    ....
}
Run Code Online (Sandbox Code Playgroud)

我有一个配置如下的测试bean:

@Component(value="testBean")
public class TestBean {
    public boolean getTestValue() {
        return true;
    }
}
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试访问testSpEL()方法时,我面临以下异常:

Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1057E:(pos 1): No bean resolver registered in the context to resolve access to bean 'testBean'
    at org.springframework.expression.spel.ast.BeanReference.getValueInternal(BeanReference.java:45)
    at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:52)
    at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:102)
    at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:97)
    at org.springframework.security.access.expression.ExpressionUtils.evaluateAsBoolean(ExpressionUtils.java:11)
Run Code Online (Sandbox Code Playgroud)

我已经彻底完成了我的研究,但我找不到我需要在配置中更改的内容才能使其工作.有什么指针吗?

谢谢!

亲切的问候,Jonck

PS我正在使用Spring 3.0.5.以下似乎表明此类功能应该起作用:

https://jira.springsource.org/browse/SPR-7173

java spring spring-security

9
推荐指数
1
解决办法
7632
查看次数

Visual Studio代码:node_modules/@types/googlemaps/index.d.ts'不是模块

我遵循了本教程: 使用Visual Studio Code(Mac上的版本1.24.1)在Angular 5中集成Google Maps以开始使用我的Angular 5应用程序中的Google Maps.直到最近一切都工作正常,但几天前(我的猜测是VS代码的更新发生在后台)我在Visual Studio代码中导入谷歌地图时出错,以前从未给我错误:

import { } from '@types/googlemaps';
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

File 'full_path/node_modules/@types/googlemaps/index.d.ts' is not a module.
Run Code Online (Sandbox Code Playgroud)

(注意full_path是完整的父路径,为简洁起见,此处未显示)

我可以看到该库位于node_modules目录中的正确位置.此外,我的package.json中正确引用了库(它的版本为3.30.10).我没有运行npm update或其间的任何其他更新,当它工作时和它开始给出错误时.

当我运行"npm start"或"npm run build"时,它运行得很好,应用程序就像之前一样(并且Google Map渲染完美),因此它似乎是Visual Studio Code问题.

从这个意义上来说,它并没有真正阻止我,但是从我的IDE中获取错误会很好.有没有人有任何关于如何摆脱错误的指针?谢谢!

编辑 我在这里阅读:如何为谷歌地图安装TS类型,有两种可能的解决方案.三重斜杠指令或改变你的tsconfig.json.对我来说,只有三斜杠指令有效:

/// <reference path="<relevant path>/node_modules/@types/googlemaps/index.d.ts" />
Run Code Online (Sandbox Code Playgroud)

仍然会对我可以导入Google地图类型的真正修复感兴趣.

typescript visual-studio-code angular

7
推荐指数
1
解决办法
2867
查看次数