【发布时间】:2023-03-30 23:37:02
【问题描述】:
这是一个非常简单的网页抓取程序,我在 intellij idea 中使用 maven 构建系统构建。它在今天之前运行良好,但是当我今天尝试构建它时,它给了我对象未找到基本 java 对象(如 String 和 List)的错误。当我尝试重新加载 maven 项目时,我在下面遇到另一个错误。 Idea 还用红色突出显示了基本的 java 对象,并且没有给出任何建议。我唯一做的就是稍微修改java源代码。因此,我使用股票 hello world 代码进行了测试。它确实编译并运行了,但 Intellij 仍然以红色突出显示字符串和系统,并且 maven 重新加载会产生相同的错误。非常感谢您的帮助,因为我需要为研究项目获取一些数据。
网页抓取源代码编译错误
Error:(24, 13) java: cannot find symbol
symbol: class List
location: class Main
Maven 重新加载错误
Cannot resolve plugin org.apache.maven.plugins:maven-compiler-plugin:${maven.compiler.version}
这是 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>org.example</groupId>
<artifactId>htmlunittest</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
<version>2.19</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.7.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
【问题讨论】:
-
进入intellij菜单文件->项目结构->项目设置->选择你的JDK
-
不幸的是,这不是问题所在。 JDK 是 11。
-
@T0m4t0s4uc3 您是否尝试将其添加到您的 pom 中?
标签: java maven intellij-idea