Reputation:
It's a very simple web scraping program that I built in intellij idea with the maven build system. It worked fine before today but when I tried to build it today it gave me object not found errors for base java objects like String and List. When I tried to reload the maven project I got another error below. Idea also highlights the basic java object in red and gives no advice. The only thing I did was slightly modify the java source code. So, I tested with the stock hello world code. It did compile and run, but Intellij still highlights String and System in red and the maven reload produces the same error. Help is greatly appreciated as I need to get some data for a research project.
Error with web scraping source code compilation error
Error:(24, 13) java: cannot find symbol
symbol: class List
location: class Main
Maven reload error
Cannot resolve plugin org.apache.maven.plugins:maven-compiler-plugin:${maven.compiler.version}
This is the pom.xml file
<?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>
Upvotes: 2
Views: 14332
Reputation: 3671
Update:
After resolving the maven errors, since you are facing IDE related problems, I would suggest you to do this:
You have forgot to define the property ${maven.compiler.version}
in your POM.
Define a properties
section in your POM like this:
<properties>
<java.version>1.11</java.version>
<maven.compiler.version>3.8.1</maven.compiler.version>
</properties>
Upvotes: 3