官术网_书友最值得收藏!

Executing life cycle phases and goals

IntelliJ provides a Maven project window; if it's not displayed, we can open it selecting on the menu: View | Tool Windows | Maven Projects.

Maven projects window

In this window, we can invoke Maven commands; for example, we can execute the compile life cycle phase by double-clicking on the corresponding option in the Maven project window. This is equivalent to entering this on the command line:

mvnw compile

Do it so it will open the Run window on the bottom-center of the screen where we can see the results of that phase. In that new window, we have a vertical button bar with more options, the top left with the green play button will rerun our last command, we can press Ctrl + F5 (command + r on Mac) to do it through a key binding.

At the top side of the Maven project's windows, we can see another horizontal bar that has additional options, the first one will refresh the Maven project and that should be done if we modify the POM, for example, to add new dependencies.

There are additional options that you can explore, but first, let's take a look at the one looking like a document with a blue m on top, that is used to execute a Maven goal. This will open a new window to type Maven goals or life cycle phases to be invoked.

This window has an autocomplete feature, so it will understand our Maven goals and phases, helping us to type our command faster. We could, for example, do a clean compilation typing in the window clean compile, this is equivalent to entering on the command line:

mvnw clean compile

Using this window, we can also directly invoke goals from the Maven plugins defined on the POM. We can, for example, expand the Plugins sections on the Maven project's window, then expand spring-boot and then double-click on spring-boot:run, this will run our microservice. This is equivalent to typing the following in the command line:

mvnw spring-boot:run

As before, the Run window will display the results. Since this command does not immediately end, we will see on the Run window a button that allows us to stop process, that effectively will stop our microservice, and we can also rerun this command if we need to, as before with using the Rerun button.

While this command is running, if we execute another command in the Maven window a new tab in the Run window will appear. We can switch them by pressing on the tab name, and each of them will show a different log and have different buttons to stop or rerun that particular command.

主站蜘蛛池模板: 托克托县| 牙克石市| 明溪县| 铜梁县| 北海市| 阳原县| 深州市| SHOW| 巴青县| 辉县市| 宁强县| 寿宁县| 莆田市| 龙游县| 南皮县| 沙河市| 尼木县| 会理县| 阳曲县| 化德县| 淮安市| 磐安县| 嘉善县| 张家港市| 鄂尔多斯市| 博白县| 南澳县| 万全县| 九龙县| 黄梅县| 玉山县| 灌南县| 云安县| 蒙山县| 武冈市| 峡江县| 重庆市| 肥西县| 临潭县| 锡林浩特市| 丹凤县|