[JAVA] Build a "Spring Thorough Introduction" development environment with IntelliJ IDEA

Make a note of how to build the development environment of "Spring thorough introduction Java application development by Spring Framework" with IntelliJ IDEA.

Create a new project

Launch IntelliJ IDEA and click Create New Project.

welcome-to-intellij-idea.png

Select the Maven project, check Create from archetype, select maven-archetype-webapp and click Next.

new-project-1.png

Give the GroupId and ArtifactId and click Next.

new-project-2.png

Check the contents and click Next.

new-project-3.png

Confirm the Project name and click Finish.

new-project-4.png

When the project is created, the Maven task will be executed, so wait until it is completed.

Modify / add files

Modify pom.xml and web.xml. Also add include.jsp.

pom.xml

Modify pom.xml as follows.

pom.xml


<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>example</groupId>
    <artifactId>firstapp</artifactId>
    <packaging>war</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>firstapp Maven Webapp</name>
    <url>http://maven.apache.org</url>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>io.spring.platform</groupId>
                <artifactId>platform-bom</artifactId>
                <version>2.0.5.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.taglibs</groupId>
            <artifactId>taglibs-standard-jstlel</artifactId>
        </dependency>
    </dependencies>
    <build>
        <finalName>firstapp</finalName>
        <pluginManagement>
            <plugins>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>

web.xml

Modify web.xml as follows.

src/main/webapp/WEB-INF/web.xml


<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
         version="3.0">
    <jsp-config>
        <jsp-property-group>
            <url-pattern>*.jsp</url-pattern>
            <page-encoding>UTF-8</page-encoding>
            <include-prelude>/WEB-INF/include.jsp</include-prelude>
        </jsp-property-group>
    </jsp-config>
</web-app>

include.jsp

Add include.jsp with the following contents.

src/main/webapp/WEB-INF/include.jsp


<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

Reimport Maven project

Right-click on the project name in the project tree and click Maven> Reimport.

maven-reimport.png

Deploy the application to tomcat

Deploy the application to Tomcat with IntelliJ IDEA.

Install tomcat

To install Tomcat with Homebrew, run the following command.

$ brew install tomcat

Add tomcat

Click Run> Edit Configurations on the menu.

When Run / Debug Configurations is displayed, click the + icon.

run-debug-configurations-1.png

Click N items more (irrelevant) in the settings list to display more, select Tomcat Server, and click Local.

add-new-configuration-1.png

add-new-configuration-2.png

add-new-tomcat-server-configuration.png

Specify Tomcat Home and click OK.

tomcat-server.png

Select the added Tomcat Server and click the Deployment tab.

run-debug-configurations-2.png

Click the + icon and click Artifact.

run-debug-configurations-3.png

run-debug-configurations-4.png

Select the project name to deploy. Normally you want to hot deploy, so select the one with exploded and click OK

select-artifacts-to-deploy.png

The application is now ready for deployment.

run-debug-configurations-5.png

Change On frame deactivation to Update classes and resources so that it will be hot-deployed the last time you save the file.

run-debug-configurations-6.png

Start Tomcat to access the application

Start Tomcat by running Run> Run'Tomcat v8.5' from the menu. Alternatively, select Tomcat v8.5 in the Application Servers pane and click the Run icon to launch it.

When the browser starts after the server starts and the page "Hello World!" Is displayed, the development environment construction is complete.

Recommended Posts

Build a "Spring Thorough Introduction" development environment with IntelliJ IDEA
Build a PureScript development environment with Docker
Build a Wordpress development environment with Docker
Build a WordPress development environment quickly with Docker
[Win10] Build a JSF development environment with NetBeans
Create a Spring Boot development environment with docker
Build a Java development environment with VS Code
[Environment construction] Build a Java development environment with VS Code!
Build a Node.js environment with Docker
Build a Tomcat 8.5 environment with Pleiades 4.8
Build jooby development environment with Eclipse
Build WebAPP development environment with Java + Spring with Visual Studio Code
Build a development environment for Django + MySQL + nginx with Docker Compose
Steps to build a Ruby on Rails development environment with Vagrant
We will build a Spring Framework development environment in the on-premises environment.
Create Spring Boot-gradle-mysql development environment with Docker
Build a Java development environment on Mac
Build a simple Docker + Django development environment
Build a hot reload development environment with Docker-compose using Realize of Go
I tried to build a Firebase application development environment with Docker in 2020
[Copy and paste] Build a Laravel development environment with Docker Compose Part 2
How to build a Ruby on Rails development environment with Docker (Rails 6.x)
Build a local development environment for Rails tutorials with Docker (Rails 6 + PostgreSQL + Webpack)
[Copy and paste] Build a Laravel development environment with Docker Compose Participation
Build a development environment on AWS EC2 with CentOS7 + Nginx + pm2 + Nuxt.js
How to build a Ruby on Rails development environment with Docker (Rails 5.x)
Template: Build a Ruby / Rails development environment with a Docker container (Ubuntu version)
Template: Build a Ruby / Rails development environment with a Docker container (Mac version)
Introduction to Java development environment & Spring Boot application created with VS Code
Build a development environment for Docker + Rails6 + Postgresql
Let's get started with Java-Create a development environment ②
Let's get started with Java-Create a development environment ①
[Windows] [IntelliJ] [Java] [Tomcat] Create a Tomcat9 environment with IntelliJ
Build a Laravel / Docker environment with VSCode devcontainer
Development environment construction using IntelliJ IDEA + Maven + Tomcat 9
Build Spring Boot project by environment with Gradle
Build a development environment for Docker, java, vscode
[First team development ②] Build an environment with Docker
Build a WEB system with Spring + Doma + H2DB
Build a development environment to create Ruby on Jets + React apps with Docker
Try modding with Minecraft Forge 1.15.1 ① [Building development environment] [Multiple versions supported] [IntelliJ IDEA]
Build a WEB system with Spring + Doma + H2DB + Thymeleaf
Build a Ruby on Rails development environment on AWS Cloud9
Easily build a Vue.js environment with Docker + Vue CLI
[Note] Build a Python3 environment with Docker in EC2
Build Java development environment with WSL2 Docker VS Code
How to build Java development environment with VS Code
Try to build a Java development environment using Docker
Build Java program development environment with Visual Studio Code
Java + Spring development environment construction with VirtualBox + Ubuntu (Xfce4)
Build a WEB system with Spring + Doma + H2DB Part 2
Until you build a Nuxt.js development environment with Docker and touch it with VS Code
How to quit Docker for Mac and build a Docker development environment with Ubuntu + Vagrant
JavaFX application development with IntelliJ IDEA and Gradle ~ From environment construction to sample code ~
I tried to create a java8 development environment with Chocolatey
I made a development environment with rails6 + docker + postgreSQL + Materialize.
Build a local development environment for Rails tutorials with Docker-Introduce Bootstrap and Font Awesome with Webpack-
Hot deploy with IntelliJ IDEA
Build docker environment with WSL
Build a CentOS 8 virtual environment on your Mac with VirtualBox
How to build Rails, Postgres, ElasticSearch development environment with Docker