eclipse+maven+spring mvc項(xiàng)目基本搭建過程
環(huán)境
操作系統(tǒng)
windows10
JDK
jdk1.8.0_192
IDE
Eclipse IDE for Enterprise Java Developers.
Version: 2019-06 (4.12.0) Build id: 20190614-1200
目錄結(jié)構(gòu)


構(gòu)建
1.配置settings.xml
創(chuàng)建一個(gè)settings.xml文件,復(fù)制下列代碼到文件中
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<!-- 本地maven庫路徑 -->
<localRepository>D:\DxOffice\repository</localRepository>
<!-- 中央maven庫 -->
<mirrors>
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>*</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
</mirrors>
</settings>
配置
Window -> Preferences

Maven -> User Settings -> User Settings ->Browse...->Apply and Close

2.創(chuàng)建Maven項(xiàng)目
File -> New ->Maven Project(/Other...->Maven Project -> Next)


Next

org.apache.maven.archetypes maven-archetype-webapp 1 .0->Next

Group Id、Artifact Id、Version、Package -> Finish

3.修改JRE
Build Path

Configure Build Path...

Libraries -> JRE System Library -> Edit

Workspace default JRE ->Finish

4.配置pom.xml
修改<dependencies></dependcies>內(nèi)代碼如下
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.17</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.servlet.jsp/jsp-api -->
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-fileupload/commons-fileupload -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.59</version>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>2.3.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.3.11.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-jdbc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>4.3.11.RELEASE</version>
</dependency>
</dependencies>
<build></build>內(nèi)添加<plugins></plugins>,代碼如下
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.3.7.v20160115</version>
<configuration>
<httpConnector>
<port>8081</port>
</httpConnector>
<webApp>
<contextPath>/${project.artifactId}</contextPath>
</webApp>
<contextHandlers>
<!-- 附件目錄服務(wù) -->
<contextHandler implementation="org.eclipse.jetty.maven.plugin.JettyWebAppContext">
<contextPath>/image</contextPath>
<resourceBase>D:\DxOffice\workspace\image</resourceBase>
</contextHandler>
</contextHandlers>
<encoding>UTF-8</encoding>
<scanIntervalSeconds>10</scanIntervalSeconds>
</configuration>
</plugin>
<!-- 要解決靜態(tài)文件鎖定問題org\eclipse\jetty\jetty-webapp\ -->
<!-- org\eclipse\jetty\webapp\webdefault.xml -->
<!-- <init-param> -->
<!-- <param-name>useFileMappedBuffer</param-name> -->
<!-- <param-value>true</param-value> change to false -->
<!-- </init-param> -->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<path>/${project.artifactId}</path>
<port>8080</port>
<uriEncoding>UTF-8</uriEncoding>
<finalName>${project.artifactId}</finalName>
<server>tomcat7</server>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
5.主目錄結(jié)構(gòu)搭建

M
model
V
view
C
controller
service
總結(jié)
以上所述是小編給大家介紹的eclipse+maven+spring mvc項(xiàng)目基本搭建過程,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
如果你覺得本文對你有幫助,歡迎轉(zhuǎn)載,煩請注明出處,謝謝!
- 詳解Spring與Mybatis的整合方法(基于Eclipse的搭建)
- 基于IDEA,Eclipse搭建Spring Boot項(xiàng)目過程圖解
- Java+Eclipse+Selenium環(huán)境搭建的方法步驟
- 基于Eclipse 的JSP/Servlet的開發(fā)環(huán)境的搭建(圖文)
- 如何使用eclipse搭建maven多module項(xiàng)目(構(gòu)建父子項(xiàng)目)
- JAVA環(huán)境搭建之MyEclipse10+jdk1.8+tomcat8環(huán)境搭建詳解
- eclipse下搭建hibernate5.0環(huán)境的步驟(圖文)
- JavaEE開發(fā)基于Eclipse的環(huán)境搭建以及Maven Web App的創(chuàng)建
- Eclipse搭建Android開發(fā)環(huán)境(安裝ADT,Android4.4.2)
- eclipse如何搭建Springboot項(xiàng)目詳解
相關(guān)文章
java?Springboot對接開發(fā)微信支付詳細(xì)流程
最近要做一個(gè)微信小程序,需要微信支付,所以研究了下怎么在java上集成微信支付功能,下面這篇文章主要給大家介紹了關(guān)于java?Springboot對接開發(fā)微信支付的相關(guān)資料,需要的朋友可以參考下2024-08-08
Java BufferedReader相關(guān)源碼實(shí)例分析
這篇文章主要介紹了Java BufferedReader相關(guān)源碼實(shí)例分析,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-10-10
解決子線程中獲取不到HttpServletRequest對象的問題
這篇文章主要介紹了解決子線程中獲取不到HttpServletRequest對象的問題,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-07-07
SpringBoot應(yīng)用的接口訪問從HTTP改為HTTPS
本文主要介紹了SpringBoot應(yīng)用的接口訪問從HTTP改為HTTPS,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2025-03-03
Java之通過OutputStream寫入文件與文件復(fù)制問題
這篇文章主要介紹了Java之通過OutputStream寫入文件與文件復(fù)制問題,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-04-04
Java SSM實(shí)現(xiàn)前后端協(xié)議聯(lián)調(diào)詳解上篇
首先我們已經(jīng)知道,在現(xiàn)在流行的“前后端完全分離”架構(gòu)中,前后端聯(lián)調(diào)是一個(gè)不可能避免的問題,這篇文章主要介紹了Java SSM實(shí)現(xiàn)前后端協(xié)議聯(lián)調(diào)過程2022-08-08

