小编pCh*_*hip的帖子

如何在spring-security-javaconfig中添加Access Denied Handler

我正在使用spring-security-javaconfig库来实现Spring安全性.如果我使用xml配置文件,我会使用类似这样的内容来定义自定义访问被拒绝页面:

<http auto-config="true">
    <intercept-url pattern="/admin*" access="ROLE_ADMIN" />
    <access-denied-handler ref="accessDeniedHandler"/>
</http>
Run Code Online (Sandbox Code Playgroud)

到目前为止,这是我的安全配置类:

@Configuration
@EnableWebSecurity
public class SecurityConfigurator extends WebSecurityConfigurerAdapter {

    @Override
    protected void registerAuthentication(AuthenticationManagerBuilder auth)
            throws Exception {
        auth.inMemoryAuthentication().withUser("user").password("password").roles("USER");
        auth.inMemoryAuthentication().withUser("admin").password("password").roles("ADMIN");

    }

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.authorizeUrls().antMatchers( "/admin").hasRole("ADMIN");
    }
}
Run Code Online (Sandbox Code Playgroud)

java spring-security spring-java-config

16
推荐指数
1
解决办法
1万
查看次数

Visual Studio Code:格式化 Java 方法链

我正在尝试更改 VSCode 设置,这将允许我使用方法链接执行类似操作:

Flux
  .just("test", "string", "flux")
  .log()
  .map(String::toUpperCase);
Run Code Online (Sandbox Code Playgroud)

问题是每当应用格式化程序时,它都会将其更改回一行:

Flux.just("test", "string", "flux").log().map(String::toUpperCase);
Run Code Online (Sandbox Code Playgroud)

我安装了 Java 扩展包,其中包括“Red Hat 对 Java 的语言支持”。该扩展程序添加了一些格式选项,我一直在尝试使用它们,但没有这样的运气。

以下是我更改的格式选项:

"editor.formatOnSave": true,
"java.format.settings.url": "https://raw.githubusercontent.com/google/styleguide/gh-pages/eclipse-java-google-style.xml",
"java.format.enabled": true,
"java.format.settings.profile": "GoogleStyle"
Run Code Online (Sandbox Code Playgroud)

任何人都知道如何让格式化程序单独保留多行方法链接?

java visual-studio-code vscode-settings

9
推荐指数
2
解决办法
3814
查看次数