Spring 添加依赖项后,可以';导入依赖类
将依赖项添加到POM.xml文件并使用mvn dependency:resolve重建后,我无法在类中导入依赖项。例如,我在pom.xml文件中添加了安全依赖项,但无法从org.springframework导入Spring引导安全包。。。 上面说这个符号无法解析 我试着重建我的项目,但没有成功。只有在使用具有安全依赖项的Spring Initializer重新初始化项目时,我才能导入 我的POM:Spring 添加依赖项后,可以';导入依赖类,spring,spring-boot,spring-security,Spring,Spring Boot,Spring Security,将依赖项添加到POM.xml文件并使用mvn dependency:resolve重建后,我无法在类中导入依赖项。例如,我在pom.xml文件中添加了安全依赖项,但无法从org.springframework导入Spring引导安全包。。。 上面说这个符号无法解析 我试着重建我的项目,但没有成功。只有在使用具有安全依赖项的Spring Initializer重新初始化项目时,我才能导入 我的POM: <parent> <groupId>org.spring
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.7.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.drkalamlibrary</groupId>
<artifactId>spring-boot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spring-boot-backend</name>
<description>Presidential Library </description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</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>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
每当我尝试从SpringBoot导入安全类时,导入下都会出现一条红色下划线 删除
测试
范围后,尝试导入spring安全依赖项。像这样:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
org.springframework.boot
邮递这就是为什么不能为spring security加载导入
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>