Make a note of how to build the development environment of "Spring thorough introduction Java application development by Spring Framework" with IntelliJ IDEA.
Launch IntelliJ IDEA and click Create New Project.
Select the Maven project, check Create from archetype, select maven-archetype-webapp and click Next.
Give the GroupId and ArtifactId and click Next.
Check the contents and click Next.
Confirm the Project name and click Finish.
When the project is created, the Maven task will be executed, so wait until it is completed.
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" %>
Right-click on the project name in the project tree and click Maven> Reimport.
Deploy the application to Tomcat with IntelliJ IDEA.
To install Tomcat with Homebrew, run the following command.
$ brew install tomcat
Click Run> Edit Configurations on the menu.
When Run / Debug Configurations is displayed, click the + icon.
Click N items more (irrelevant) in the settings list to display more, select Tomcat Server, and click Local.
Specify Tomcat Home and click OK.
Select the added Tomcat Server and click the Deployment tab.
Click the + icon and click Artifact.
Select the project name to deploy. Normally you want to hot deploy, so select the one with exploded and click OK
The application is now ready for deployment.
Change On frame deactivation to Update classes and resources so that it will be hot-deployed the last time you save the file.
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