java - 导入 java bcrypt 库时遇到问题
问题描述
我在导入 Spring Security 库时遇到了问题。
这是我的主要课程:
package com.example.test.myfirstproject;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
@SpringBootApplication
public class MyFirstProjectApplication {
public static void main(String[] args) {
SpringApplication.run(MyFirstProjectApplication.class, args);
}
@Bean
public BCryptPasswordEncoder bCryptPasswordEncoder() {
return new BCryptPasswordEncoder();
}
}
还有我的 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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.5</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example.test</groupId>
<artifactId>myfirstproject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>myfirstproject</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<version>2.4.5</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
当我尝试在 IntelliJ IDEA 中构建时,出现错误:
java: package org.springframework.security.crypto.bcrypt does not exist
java: cannot find symbol
symbol: class BCryptPasswordEncoder
location: class com.example.test.myfirstproject.MyFirstProjectApplication
我对 BCryptPasswordEncoder 方法使用了自动完成功能,所以应该不会出错。我还尝试更改 pom.xml 文件中安全依赖项的位置,但它也没有帮助。
谢谢您的帮助!
解决方案
推荐阅读
- python-3.x - opencv 中的 imshow() 函数给出了一个没有响应消息的窗口
- python - 根据查询从公共页面获取 Facebook 帖子
- javascript - 如果字段超过 25 个,则发送多个嵌入 (Discord.js)
- github - 是否可以在公共存储库中拥有私有文件?
- java - Spring Security 异常处理 - 如果页面重定向到登录,如果休息 api 则发送带有错误的 json
- wordpress - 如何在wordpress woocommerce上双重计算产品?
- c++ - 将依赖项编译成库本身
- python - 使用拟合 pmdarima ARIMA 模型进行预测
- java - 指定的 minCompileSdk (31)
- windows - make (e=2): 系统找不到指定的文件