org.springframework.security.authentication.encoding在maven中不存在

时间:2018-06-25 15:24:52

标签: java maven spring-security

我见过Maven cannot compile Spring Security demo project。但是我的问题没有解决。

下面的代码中出现了问题:

    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-core</artifactId>
        <version>5.0.6.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-config</artifactId>
        <version>5.0.6.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-web</artifactId>
        <version>5.0.6.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-taglibs</artifactId>
        <version>5.0.6.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-framework-bom</artifactId>
        <version>5.0.7.RELEASE</version>
        <type>pom</type>
        <scope>import</scope>
    </dependency>

java代码(导入):

import org.springframework.security.authentication.encoding.Md5PasswordEncoder;
import org.springframework.security.authentication.encoding.ShaPasswordEncoder;

mvn compile中运行:

package org.springframework.security.authentication.encoding does not exist

2 个答案:

答案 0 :(得分:1)

已弃用。您可以尝试更换:

org.springframework.security.crypto.password.MessageDigestPasswordEncoder

更多详细信息在这里: https://docs.spring.io/spring-security/site/docs/4.2.6.RELEASE/apidocs/org/springframework/security/crypto/password/MessageDigestPasswordEncoder.html

答案 1 :(得分:1)

org.springframework.security.crypto.password.MessageDigestPasswordEncoder  也已弃用,因此我们可以使用org.springframework.security.crypto.password.DelegatingPasswordEncoder 默认情况下,它可以用于不同类型的算法,它使用bcrypt,但支持ldap,MD4,MD5,noop,pbkdf2,scrypt,SHA-1,SHA-256,sha256。