You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

不同IntelliJ IDEA社区版版本下微服务无法启动问题求助

Troubleshooting IntelliJ IDEA 2020.3.1 Microservice Startup Issue

Let's break down why your microservices fail to start in IntelliJ 2020.3.1 but work fine in 2019.3.5, and walk through actionable fixes:

1. Check JDK Version Consistency

First, verify that both IDE versions are using the exact same JDK for your project. IntelliJ 2020.3.x defaults to newer JDKs (like 11) whereas 2019.3.5 often uses JDK 8. ServiceLoader behavior changes significantly between modular (JDK 9+) and non-modular (JDK 8) environments, especially with the --add-modules/--add-opens flags you're using.

To fix:

  • Go to File > Project Structure > Project Settings > Project and confirm the Project SDK matches the one used in 2019.3.5.
  • Also check your run configuration's JRE setting under Run/Debug Configurations.

2. Fix Invalid VM Arguments

Your VM parameters have typos that likely cause permission errors in newer JDK/IDEA versions:

  • --add-opens java.management/management=ALL-UNNAMED → Should be --add-opens java.management/javax.management=ALL-UNNAMED (missing the proper package prefix)
  • --add-opens jdk.management/com.management.internal=ALL-UNNAMED → Should be --add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED (missing sun in the package path)

Older IDE/JDK versions might ignore these invalid flags, but 2020.3.1 with stricter module checks will block access, preventing ServiceLoader from loading your services. Update your VM arguments to the corrected versions and test again.

3. Verify ServiceLoader Configuration

Make sure your SomeService implementations are properly registered:

  • Confirm the META-INF/services/[fully-qualified-name-of-SomeService] file exists in each service module, with each line containing the full class name of a SomeService implementation.
  • In 2020.3.1, check your run configuration's Use classpath of module setting—ensure it includes all service modules so their classes and META-INF files are visible to the main application.

Add a debug log line to your code to see what services are actually loaded:

LOGGER.info("Loaded available services: ${availableServices.keys.joinToString(", ")}")

If this logs an empty set, the problem is definitely with ServiceLoader not finding your implementations.

4. Clear IDE Caches and Rebuild

IntelliJ 2020.3 has improved build caching, but sometimes old cached data causes classpath issues:

  • Go to File > Invalidate Caches... and select Invalidate and Restart.
  • After restart, do a full rebuild (Build > Rebuild Project) to ensure all classes and resources are generated correctly.

5. Test Outside IDE to Isolate the Issue

Run your project via the command line (using Gradle run or Maven exec:java). If it works there, the problem is specific to IntelliJ 2020.3.1's configuration:

  • Try upgrading to the latest patch version of 2020.3 (e.g., 2020.3.4) to fix any known bugs related to class loading or ServiceLoader.
  • Double-check that your run configuration doesn't have any excluded modules or classpath filters that aren't present in the 2019.3.5 setup.

内容的提问来源于stack exchange,提问作者Marouene cherdouh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.29 04:42:41