5

I did get this error message in intellij while running a spring-boot server:

'mvn' is not recognized as an internal or external command, operable program or batch file

It didnt recognize maven when I was trying to build the project standing in my projectfolder with: mvn spring-boot:run

I solved this by downloading maven: https://maven.apache.org/install.html and manually added the bin file in the apache-maven-3.5.3 folder to librarys

It seems a bit backwards. Are there any other/better way?

acroscene
  • 845
  • 4
  • 16
  • 45
  • 3
    Try adding `C:\your\path\to\maven\bin` to Windows' `Path` environment-variable. – Impulse The Fox Mar 21 '18 at 14:14
  • IntelliJ has [built in support for maven projects](https://www.jetbrains.com/help/idea/maven.html). Your mentioning of _'mvn' is not recognized_ suggests that you were trying to manually invoke maven, maybe from a terminal window?! You shouldn't be adding anything related to a maven installation to your project. You can easily build your project or run plugins from the _maven tool window_, just take a look at the link I provided for a quick intro. Alternatively if you prefer using a terminal/console, follow @ImpulseTheFox 's suggestion – Morfic Mar 21 '18 at 14:18
  • "manually invoke maven, maybe from a terminal window" no thats inside intellij. – acroscene Mar 21 '18 at 14:30
  • but is it InteliJ's terminal window? If you "type" the mvn-command, you are basically forwarding to the OS-Terminal. Hence, you will want to setup the PATH-Entry properly. – Nikolas Mar 21 '18 at 14:34
  • _"no thats inside intellij"_, ok, so how exactly are you running it when you get that message? Also please use `@username` when replying to someone's comment so they get notified – Morfic Mar 21 '18 at 14:36
  • @Morfic Im in the project root in the terminal in intellij. if I type mvn -v I get the "not recognized" message – acroscene Mar 21 '18 at 14:39
  • 2
    Precisely my point, you're not actually using the maven support from IJ. You're using the _"OS terminal wrapper"_, basically delegating to the terminal the execution of the `mvn` command. Since your system is not configured yet, it does not know what `mvn` means. @ImpulseTheFox has already provided a hint for that. Coming back to maven support in IJ, you can use the `Maven Projects` tool-window ([this one](https://www.jetbrains.com/help/img/idea/2017.3/maven_global_dependency.png) from the IJ Maven help link provided previously) to execute your build without relying on the OS config. – Morfic Mar 21 '18 at 14:46
  • @Morfic okej. so how do I ececute from Maven Projects tool-window ? – acroscene Mar 21 '18 at 14:54
  • In the documentation link I suggested, there's [a section specifically for this](https://www.jetbrains.com/help/idea/maven.html#maven_goals). In short, you usually expand the `Lifecycle` section of your project/module, and execute the desired goal. If you want to execute a goal provided by a plugin, expand the `Plugins` section and chose the desired one. Alternatively you can even define "maven run configurations" which you can execute just like launching a main class or a test. Anyway, I'd recommend you take the time to go over that link to get accustomed to how you can use maven in IJ... – Morfic Mar 21 '18 at 15:01

3 Answers3

2

If Maven is installed manually via: http://maven.apache.org/download.cgi and: 'mvn' is not recognized as an internal or external command, operable program or batch file. Just restart your IntelliJ IDEA and run your spring-boot server again!

mzhehalo
  • 78
  • 9
0

In my case, I had to uncheck Shell integration in

IntelliJIDEA Menu -> Preferences -> Tools -> Terminal

enter image description here

DaNeSh
  • 1,022
  • 1
  • 14
  • 24
0

In Windows Run your intellij as administrator

prsadrian
  • 23
  • 5
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/30036918) – Fabio Mendes Soares Oct 10 '21 at 12:05