1.File-->New-->Project-->Maven-->Project SDK:1.8(java version "1.8.0_181")
-->Create from archetype-->org.apache.maven.archetypes:maven-archetype-webapp
-->Next-->填写该填的东西-->Next-->填写该填的东西-->Finish
右下角会有个提示(Maven projects need to be imported),选择自动导入(Enable Auto-Import)
2.File-->Project Structure-->Modules-->在main下新建java、resources文件夹-->并分别指定为Sources(源文件夹)、
Resources(资源文件夹)-->Apply
3.File-->Project Structure-->Facets--> + -->Web-->Deployment Descriptors:Edit Enter(工程名\src\main\webapp\WEB-INF\web.xml)和Web Resource Directories:Edit Enter(工程名\src\main\webapp)-->Apply
4.File-->Project Structure-->Artifacts--> + -->Web Application:Exploded-->From Modules-->Apply
5.部署tomcat:Add Configuration--> + -->Tomcat Server-->Local-->Server:该填写的填写-->Deployment
--> + -->Artifact-->Apply
6.web.xml的内容改为
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
</web-app>
7.添加自定义jsp模板:File-->Settings-->Editor-->File and Code Templates-->Other-->Jsp files-->Jsp File.jsp-->Apply
Jsp File.jsp内容改为
<%--
Created by IntelliJ IDEA.
User: ${USER}
Date: ${DATE}
Time: ${TIME}
To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" import="java.util.*"
contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE HTML>
<html>
<head>
<base href="<%=basePath%>">
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
</body>
</html>
8.引入servlet的相关依赖
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
9.运行tomcat调试
10.上传至远程仓库gitee
1)新建仓库,仓库名即填项目名,是否开源:公开
选择语言:Java,添加.gitignore:Java,使用Readme文件初始化这个仓库
选择分支模型:单分支模型(只创建master分支)
2)打开Git Bash Here
$ git clone https://gitee.com/myideato/idea-ssm-blog.git
3)将.git .gitignore README.en.md README.md复制,然粘贴至对应项目文件夹里
4)编写.gitignore文件,往里面添写target 、out 、static(放置静态资源的如*.html,并且它们与项目无关)
5)最后分别执行git add .,git commit -m "描述",git push
基于idea搭建maven项目
最新推荐文章于 2020-08-21 16:37:15 发布