STS 3.9.2 Oxygen在JDK9下抽象类报错问题求助
Hey there, let's work through this frustrating issue you're hitting with your WebElement implementation in STS 3.9.2 on Ubuntu 16.04 with JDK 9.0.4. It's super weird that Maven command-line works but Eclipse throws errors—this almost always boils down to IDE-specific Java 9 compatibility quirks, since Oxygen-era STS had spotty support for the newer JDK version. Here are the steps to fix it:
1. Install Java 9 Support Patches for Eclipse Oxygen
STS 3.9.2 is built on Eclipse Oxygen, which only had preview support for Java 9 out of the box. You'll need to install the official Java 9 support plugin to get proper compiler handling:
- Open STS, go to
Help > Eclipse Marketplace - Search for "Java 9 Support for Oxygen" (look for the plugin from Eclipse JDT)
- Install the plugin, then restart STS completely
2. Tweak Project Compiler & Build Path Settings
Double-check that your project is fully configured for Java 9 in Eclipse:
- Right-click your project >
Properties > Java Compiler- Set Compiler compliance level to
9 - Uncheck "Use default compliance settings" temporarily to confirm
source,target, andreleaseare all set to9
- Set Compiler compliance level to
- Go to
Java Build Path > Libraries- Ensure the JRE System Library is pointing to JDK 9.0.4 (not a JRE or older JDK)
- If it's not, click
Add Library > JRE System Libraryand select your JDK 9 installation
3. Sync Maven Configuration with Eclipse
Since you updated the Maven compiler plugin, make sure Eclipse picks up those changes correctly:
- First, verify your
maven-compiler-pluginconfig is Java 9-compatible (use a version that supports JDK 9, like 3.8.0 or newer):<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.0</version> <configuration> <release>9</release> </configuration> </plugin> - Right-click your project >
Maven > Update Project... - Check "Force Update of Snapshots/Releases" and click OK to sync Eclipse's settings with your pom.xml
4. Clean Up Auto-Generated Methods
When you let Eclipse auto-complete missing methods for WebElement, it might incorrectly generate methods that are actually default methods in the WebElement interface (Java 8+ allows interfaces to have default implementations). These shouldn't be in your implementation class:
- Delete any auto-generated methods that have the
defaultmodifier - If Eclipse still complains, run
Project > Clean...to wipe old compiled files and recompile from scratch
5. Upgrade STS (If All Else Fails)
STS 3.9.2 is pretty outdated, and later versions (like 3.9.10 or newer) have much better Java 9 support. If the above steps don't resolve the issue, upgrading to a more recent STS build will likely fix the compatibility gaps between the IDE and JDK 9.
内容的提问来源于stack exchange,提问作者user871199

