Elena Alexandra Dobrescu Elena Alexandra Dobrescu - 1 month ago 22
Java Question

stormpath() method is undefined Spring boot

I am new to Stormpath and Spring boot and I have been trying to follow some tutorials.

I have the following dependencies in my 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>


Here is my configuration class:

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());
}
}


When I write this piece of code I am getting an error saying that The method stormpath() is undefined for the type SecurityConfiguration.I suppose the method should have been inherited from WebSecurityConfigurerAdapter, but when I checked the class the method is not defined. How should I solve this problem?

Answer

You can use this dependency

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

and than import the missing static method:

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