Development environment construction using IntelliJ IDEA + Maven + Tomcat 9

Introduction

As the title suggests, the contents when building the development environment are described. There were several articles that looked like it in the same environment, but there were times when the settings were different at key points and I couldn't run it in my environment, so I'll leave it as a memorandum.

In this article The procedure from Tomcat installation to server startup to deployment is described. The target environment is ** macOS 10.13.4 **.

Tomcat installation and Maven settings

1. Install Tomcat

Download it from Apache Tomcat (http://tomcat.apache.org/) and deploy it locally. Alternatively, install Tomcat with the brew command (as of April 17, 2018, ** Tomcat 9.0.6 ** will be installed).

If you installed it with the brwe command, it will be installed in the following location.

-** /tomcat/9.0.6 **

2. Tomcat Manager settings

Set the user (ʻuser) and role (role`) in ** tomcat-users.xml ** to use Tomcat Manager.

** tomcat-users.xml ** is stored in the following location.

-** /tomcat/9.0.6/libexec/conf **

<role rolename="manager-script"/>
<role rolename="manager-gui"/>
<user username="admin" password="admin" roles="manager-script,manager-gui"/>

The meaning of the roll is as follows.

  • From the original document * Access to the HTML interface
  • From the original document * Access to the tools-friendly plain text interface that is described in this document, and to the "Server Status" page.

For the time being, set the above role so that it can be used from the browser and tools.

3. Server settings in Maven config file

Set the server (server) in ** settings.xml ** first so that it can be accessed from the Maven plugin that will be used later.

The storage location of ** settings.xml ** varies depending on the settings, but by default it is stored in the following location.

-** /. M2 **

<servers>
   <server>
     <id>localhost</id>
     <username>admin</username>
     <password>admin</password>
   </server>
</servers>

Set the server ID (optional) and the user name and password of the administrator user you added earlier.

Application creation and server startup

4. Create an application in IntelliJ

Start IntelliJ and select New-> Project. Next, the [New Project] dialog is displayed. As shown in the image, select [** Maven **]-> [Create from archetype]-> [maven-archetype-webapp] and click [Next]. To do.

01_intellij_new_project.png

Enter the GroupId and ArtifactId and click Next.

02_intellij_new_project.png

If you are satisfied with the contents, click [Next].

03_intellij_new_project.png

Specify where you want to save the project and click Finish. 04_intellij_new_project.png

This is the end of project creation. When the project screen opens, it is convenient to set automatic repository download.

5. Tomcat settings

Next, modify ** pom.xml **. Here, we will add only the plugin. In configuration, specify ʻid added to settings.xmlin`.

05_intellij_pom_edit.png

Click Edit Configurations ... in the upper right.

06_intellij_edit_configuration.png

Select Tomcat Server-> Local from the left pane. Then click Configure in the upper right.

07_intellij_tomcat_setting.png

In the Tomcat Server dialog, for Tomcat Home, specify the Tomcat installation directory. In this case, it will be ** /tomcat/9.0.6/libexec**. Click OK when you are done.

08_intellij_tomcat_setting.png

Return to the [Server] screen, confirm that ** Tomcat 9.0.6 ** is displayed in [Application Server], and click [OK].

09_intellij_tomcat_setting.png

Then click the + button in the upper left and select Tomcat Server-> Local.

10_intellij_tomcat_add_setting.png

Enter an arbitrary setting name (demo-server) in [Name], and select ** Tomcat 9.0.6 ** in [Application Server]. Then click Deployment.

11_intellij_tomcat_add_setting.png

Click the [+] button. Then, in the Select Artifacts Deploy dialog, select the application (demo.war) you want to deploy and click OK.

12_intellij_tomcat_add_setting.png

In Application context, set the context root and click OK.

13_intellij_tomcat_add_setting.png

6. Start and redeploy Tomcat

Return to the top screen, set the upper right to [demo-server], and click the Run [>] button.

14_intellij_top.png

The console will be output at the bottom of the screen, so check that there are no errors.

15_intellij_run_server.png

Confirm that the top page is displayed. By default, ** Hello World! ** is output.

16_welcom_page.png

With the flow up to this point, it was confirmed that the server started and the top screen was displayed. Next, modify the file and check the flow of deployment.

Go back to IntelliJ and fix the JSP. This time, we will modify Hello World! To Hello World !!!. Then click Maven Project-> tomcat7: deploy.

17_intellij_edit_jsp.png

The console will be output at the bottom of the screen, so check that there are no errors.

18_intellij_app_deploy.png

Go back to your browser and reload the screen you were viewing earlier. Make sure it changes to Hello World !!!.

19_reload_welcome_page.png

Finally

It looks like a lengthy procedure, but thank you for reading to the end.

This time, I tried to build a development environment with a configuration that was often used until now. As for me, in my current work, I am working in an environment such as Windows + Eclipse + Tomcat, so I got stuck in the Maven plug-in setting part and IntelliJ setting part, but I checked it and it works. I'm glad that I was able to confirm up to that point.

If you have any questions about this article, please let us know.

Recommended Posts

Development environment construction using IntelliJ IDEA + Maven + Tomcat 9
Minecraft Mod development environment construction (IntelliJ IDEA + Minecraft Forge 1.15.2) + Hello World Mod creation
java development environment construction
IntelliJ + Docker (APP + DB) + SpringBoot (Maven) environment construction
Django development environment construction using Docker-compose (personal memorandum)
Rails6 development environment construction [Mac]
Try using IntelliJ IDEA once
JavaFX application development with IntelliJ IDEA and Gradle ~ From environment construction to sample code ~
Build a "Spring Thorough Introduction" development environment with IntelliJ IDEA
Environment construction for Servlet application development
[Unity] Android development environment construction procedure
Spring5 MVC Web application development with Visual Studio Code Environment construction (Installation of JDK11, Maven, Tomcat, Visual Studio Code)
Java runtime environment construction method (Tomcat @ Linux)
CentOS8 + Anaconda + Django development environment construction procedure
[Processing x Java] Construction of development environment
Laravel development environment construction with Docker (Mac)
Sapper × Go (echo) × Docker development environment construction
Universal Robotics UR Caps development environment construction
Java development environment construction memo on Mac
Building a Kotlin development environment using SDKMAN
[Docker] Development environment construction Rails6 / Ruby2.7 / MySQL8
Spring Boot + Docker Java development environment construction
Try Spring Boot 1 (Environment construction ~ Tomcat startup)
Edit maven settings.xml built into IntelliJ IDEA
Try modding with Minecraft Forge 1.15.1 ① [Building development environment] [Multiple versions supported] [IntelliJ IDEA]
[Jakarta EE 8 application development with Gradle] 1. Environment construction
[Windows] [IntelliJ] [Java] [Tomcat] Create a Tomcat9 environment with IntelliJ
Environment construction procedure for using PowerMock with JUnit
Deploy Azure Functions using Maven under Proxy environment
Kaggle environment construction using official Docker and vscode
[Ubuntu 18.04] Environment construction for using PyTorch with RTX3090
Create a Spring Boot application using IntelliJ IDEA
[Note] Struts2 environment construction using Gradle in Eclipse
Allow development in Eclipse environment using iPLAss SDK
A reminder of Docker and development environment construction
Ruby on Rails development environment construction on M1 Mac
I tried using the profiler of IntelliJ IDEA
Wordpress local environment construction & development procedure with Docker
Try using Maven
[Java] Environment construction
Java environment construction
Java development environment
[Spring] Environment construction
Docker environment construction
IntelliJ IDEA settings
Create a Java development environment using jenv on Mac
[Environment construction] Ruby on Rails 5.2 system development environment construction [within 1 hour]
Introduction to Slay the Spire Mod Development (2) Development Environment Construction
Prepare the execution environment of Tomcat in IntelliJ Community
Java development environment construction on Mac-JDK Install (2020 preservation version)
BEAR application Docker development environment construction example (docker-sync, Mutagen)
[Mac] VS Code development environment construction (Java, Gradle, Node.js)
Stable development environment construction manual for "Rails6" with "Docker-compose"
TDD study # 1 environment construction & first test-driven development (July 6th, 2020)
Ruby on Rails environment construction using VirtualBox, Vagrant, cyberduck
[Environment construction] Build a Java development environment with VS Code!
Try to build a Java development environment using Docker
Java + Spring development environment construction with VirtualBox + Ubuntu (Xfce4)
Construction of data analysis environment using Docker (personal memorandum)