Spring saml demo构建问题

时间:2017-07-17 17:07:29

标签: java spring maven saml-2.0 spring-saml

我们公司正计划迁移到使用SAML进行身份验证,所以我正在使用示例演示来学习如何使用spring框架和Okta实现saml。我正在按照教程(这里:https://www.youtube.com/watch?v=JBtyGfrz-jA),但是当我到达实现SecurityConfiguration的部分(视频的~5:09)时,它会抛出错误代码:

import static org.springframework.security.extensions.saml2.config.SAMLConfigurer.saml;

当我尝试构建项目时,它会抛出:

com/example/SecurityConfiguration.java:[3,67] package org.springframework.security.extensions.saml2.config does not exist
com/example/SecurityConfiguration.java:[3,1] static import only from classes and interfaces
com/example/SecurityConfiguration.java:[39,20] cannot find symbol

我认为问题在于maven导入了错误的jar文件,但是我已经尝试了许多不同版本的org.springframework.security.extensions,但没有一个允许SecurityConfiguration.java找到saml()方法。

这是pom.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>demo</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.4.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-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.security.extensions</groupId>
            <artifactId>spring-security-saml-dsl</artifactId>
            <version>1.0.0.M3</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <repositories>
        <repository>
            <id>spring-snapshots</id>
            <name>Spring Snapshots</name>
            <url>https://repo.spring.io/libs-milestone</url>
        </repository>
    </repositories>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>


</project>

1 个答案:

答案 0 :(得分:0)

当将spring-security-saml-dsl(注意:不是spring-security-saml2-core)从1.0.2.RELEASE移至1.0.3.RELEASE时,Spring破坏了他们的项目文件。

将spring-security-saml-dsl的版本更改为1.0.2.RELEASE后,应解决此问题。