搭建eclipse+maven+springmvc项目的示例

小编给大家分享一下搭建eclipse+maven+spring mvc项目的示例,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!

沂源网站制作公司哪家好,找成都创新互联公司!从网页设计、网站建设、微信开发、APP开发、成都响应式网站建设等网站项目制作,到程序开发,运营维护。成都创新互联公司自2013年起到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选成都创新互联公司

环境

操作系统

windows10

JDK

jdk1.8.0_192

IDE

Eclipse IDE for Enterprise Java Developers.

Version: 2019-06 (4.12.0) Build id: 20190614-1200

目录结构 

搭建eclipse+maven+spring mvc项目的示例

搭建eclipse+maven+spring mvc项目的示例

构建

1.配置settings.xml

创建一个settings.xml文件,复制下列代码到文件中

<?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

搭建eclipse+maven+spring mvc项目的示例

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

搭建eclipse+maven+spring mvc项目的示例

2.创建Maven项目

File -> New ->Maven Project(/Other...->Maven Project -> Next)

搭建eclipse+maven+spring mvc项目的示例

搭建eclipse+maven+spring mvc项目的示例

Next 

搭建eclipse+maven+spring mvc项目的示例

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

搭建eclipse+maven+spring mvc项目的示例

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

搭建eclipse+maven+spring mvc项目的示例

3.修改JRE

Build Path 

搭建eclipse+maven+spring mvc项目的示例

Configure Build Path...

搭建eclipse+maven+spring mvc项目的示例

Libraries -> JRE System Library -> Edit

搭建eclipse+maven+spring mvc项目的示例

Workspace default JRE ->Finish

搭建eclipse+maven+spring mvc项目的示例

4.配置pom.xml

修改<dependencies></dependcies>内代码如下

<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>内添加<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>
             <!-- 附件目录服务 -->
             <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>
       <!-- 要解决静态文件锁定问题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.主目录结构搭建

搭建eclipse+maven+spring mvc项目的示例

M

model

V

view

C

controller

service

看完了这篇文章,相信你对“搭建eclipse+maven+spring mvc项目的示例”有了一定的了解,如果想了解更多相关知识,欢迎关注创新互联行业资讯频道,感谢各位的阅读!

新闻标题:搭建eclipse+maven+springmvc项目的示例
本文来源:https://www.cdcxhl.com/article32/iechsc.html

成都网站建设公司_创新互联,为您提供响应式网站做网站网站设计公司移动网站建设商城网站全网营销推广

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

成都seo排名网站优化