首页 > 解决方案 > 无法从 Windows IntelliJ 在 WSL2 中编译 Maven 项目

问题描述

我正在尝试将 IntelliJ 与 WSL2 一起使用,但我遇到了问题。我用一个简单的主类打印 hello world 创建了一个虚拟项目。我将项目放在我的 WSL 文件系统中。当我尝试使用 IntelliJ 运行/构建时,我收到以下消息:

Maven resources compiler: Maven project configuration required for module 'testproject' isn't available. Compilation of Maven projects is supported only if external build is started from an IDE.

为什么会这样?我可以使用sudo apt get install maven从 WSL2 Ubuntu 终端下载的 maven 构建项目。

标签: windowsmavenwsl-2

解决方案


这可能是因为您的项目位于 Windows 文件系统中。为了解决这个问题,当您创建或打开一个项目时,请确保它的位置位于 wsl 目录中(例如 -> \wsl$\Ubuntu\home\andre\IdeaProjectsInWSL\MyProject)。

项目地点

https://www.jetbrains.com/help/idea/how-to-use-wsl-development-environment-in-product.html#crete_project_for_wsl


推荐阅读