gpt4 book ai didi

java - stormpath() 方法未定义 Spring boot

转载 作者:行者123 更新时间:2023-11-29 04:38:33 26 4
gpt4 key购买 nike

我是 Stormpath 和 Spring boot 的新手,我一直在尝试学习一些教程。

我的 pom.xml 中有以下依赖项

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
<dependency>
<groupId>com.stormpath.spring</groupId>
<artifactId>stormpath-thymeleaf-spring-boot-starter</artifactId>
<version>1.0.RC8.3</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
</dependencies>

这是我的配置类:

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.SecurityConfigurerAdapter;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;


@Configuration
public class SecurityConfiguration extends WebSecurityConfigurerAdapter{

@Override
protected void configure(HttpSecurity http) throws Exception {
http.apply(stormpath());
}
}

当我写这段代码时,我收到一条错误消息,指出方法 stormpath() 未定义类型 SecurityConfiguration。我想该方法应该是从 WebSecurityConfigurerAdapter 继承的,但是当我检查该类时,该方法不是定义。我该如何解决这个问题?

最佳答案

你可以使用这个依赖

<dependency>
<groupId>com.stormpath.spring</groupId>
<artifactId>stormpath-default-spring-boot-starter</artifactId>
<version>${stormpath.version}</version>
</dependency>

然后导入缺少的静态方法:

import static com.stormpath.spring.config.StormpathWebSecurityConfigurer.stormpath;

关于java - stormpath() 方法未定义 Spring boot,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40226747/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com