Mac环境下Spring Roo安装启动失败问题求助
解决Spring Roo 2.0.0.RELEASE启动卡住/依赖错误的问题
Hey there, let's fix this Spring Roo startup issue you're running into! From the error logs and your description, here's a breakdown of what's going wrong and how to get things working:
问题根源
Your core issue stems from Java version compatibility combined with OSGi bundle dependency failures:
- Spring Roo 2.0.0.RELEASE was built for Java 8, but you're likely running a newer Java version (9+). Java 9 introduced the module system, which restricts reflective operations used by older libraries like Apache Felix (the OSGi framework Roo relies on)—that's what the "illegal reflective access" warnings are about.
- The critical error is that the
org.springframework.roo.wrapping.antlr4-runtimebundle can't find thejavax.annotation.processingpackage. This package's accessibility changed in Java 9+, breaking Roo's older dependency chain.
解决方案
1. 切换到Java 8环境(最稳妥的修复)
This will resolve both the dependency error and the reflective access warnings:
- First, check your current Java version:
java -version - If it shows Java 9 or higher, install Java 8 (e.g., AdoptOpenJDK 8 or Oracle JDK 8).
- Temporary terminal setup: Run these commands to switch your terminal session to Java 8 (replace the path with your actual Java 8 installation):
export JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home export PATH=$JAVA_HOME/bin:$PATH - Permanent setup:
- On macOS/Linux: Add the above lines to your
~/.bash_profileor~/.zshrcfile, then runsource ~/.bash_profile(or the corresponding file for your shell) to apply changes. - On Windows: Go to System Properties > Advanced > Environment Variables, add/modify
JAVA_HOMEto point to your Java 8 path, and updatePATHto include%JAVA_HOME%\bin.
- On macOS/Linux: Add the above lines to your
- Verify the switch worked:
It should display a Java 8 version number.java -version
2. 重新启动Spring Roo
- For terminal users: Run the
roocommand again—it should load fully without the dependency error. - For STS users:
- Open STS and go to
Window > Preferences > Java > Installed JREs. - Add your Java 8 installation and set it as the default JRE.
- Restart STS, then launch the Roo Shell again—it won't get stuck on the loading prompt anymore.
- Open STS and go to
3. 可选:升级Spring Roo版本
If you need to use a newer Java version, consider upgrading to Spring Roo 2.0.1.RELEASE or later. These releases have improved compatibility with Java 9+ and fix many module system-related issues.
你在终端遇到的完整错误日志:
WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.apache.felix.framework.util.SecureAction (file:/Users/tkhader/Documents/Junk/RooAutogen/spring-roo-2.0.0.RELEASE/bin/org.apache.felix.framework-5.4.0.jar) to method java.net.URLClassLoader.addURL(java.net.URL) WARNING: Please consider reporting this to the maintainers of org.apache.felix.framework.util.SecureAction WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release ERROR: Bundle com.github.antlrjavaparser.antlr-java-parser [1] Error starting file:/Users/tkhader/Documents/Junk/RooAutogen/spring-roo-2.0.0.RELEASE/bundle/antlr-java-parser-1.0.15.jar (org.osgi.framework.BundleException: Unable to resolve com.github.antlrjavaparser.antlr-java-parser [1](R 1.0): missing requirement [com.github.antlrjavaparser.antlr-java-parser [1](R 1.0)] osgi.wiring.package; (osgi.wiring.package=org.antlr.v4.runtime.atn) [caused by: Unable to resolve org.springframework.roo.wrapping.antlr4-runtime [81](R 81.0): missing requirement [org.springframework.roo.wrapping.antlr4-runtime [81](R 81.0)] osgi.wiring.package; (osgi.wiring.package=javax.annotation.processing)] Unresolved requirements: [[com.github.antlrjavaparser.antlr-java-parser [1](R 1.0)] osgi.wiring.package; (osgi.wiring.package=org.antlr.v4.runtime.atn)]) org.osgi.framework.BundleException: Unable to resolve com.github.antlrjavaparser.antlr-java-parser [1](R 1.0): missing requirement [com.github.antlrjavaparser.antlr-java-parser [1](R 1.0)] osgi.wiring.package; (osgi.wiring.package=org.antlr.v4.runtime.atn) [caused by: Unable to resolve org.springframework.roo.wrapping.antlr4-runtime [81](R 81.0): missing requirement [org.springframework.roo.wrapping.antlr4-runtime [81](R 81.0)] osgi.wiring.package; (osgi.wiring.package=javax.annotation.processing)] Unresolved requirements: [[com.github.antlrjavaparser.antlr-java-parser [1](R 1.0)] osgi.wiring.package; (osgi.wiring.package=org.antlr.v4.runtime.atn)] at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4111) at org.apache.felix.framework.Felix.startBundle(Felix.java:2117) at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1371) at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308) at java.base/java.lang.Thread.run(Thread.java:844)
内容的提问来源于stack exchange,提问作者Tanzil Khader
相关产品推荐
相关产品推荐

