开发工具与关键技术:Eclipse、java
作者:张俊辉
撰写时间:2020年05月8日
在Maven搭建好后就要在Eclipse中使用Maven了,首先打开Eclipse找到Window–>Preference
如下图:
进去后找到Maven–>User Settings菜单,如下图:
在这里插入图片描述在这里插入图片描述在这里插入图片描述
把第一第二项都设置为Maven的配置文件(settings.xml)项然后点击Update Settings 更新,
如下图:
开始新增Maven Project,点击File–>New–>Oter,看到如下图所示后在搜索框中输入Maven找
到Maven Project 后选中,如下图:
点击Next >再点击Next >来到如下图画面,由于加载问题可能会如下图所示没有任何选项,你
可以等待一会儿
也可以在第一选项中把All Cataloge更换成Internal,更换后如下图所示,选中webapp:
然后点击下一步Next >填写GroupId(公司或组织Id)、ArtifactId(项目名称)、Version(版本
号)填写完成后点击Finish,如下图:
新增完成后修改jdk版本为1.7,打开项目属性(Properties),在项目根目录中右键选中
Properties找到Java Compiler去掉第二个勾选把1.5改为1.7如下图
修改web.xml文件,目录如下所示:
打开后修改为:
<web-app version="3.0"
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">
<display-name>Archetype Created Web Applicationdisplay-name>
web-app>
修改版本,首先打开Navigator视图,选中Window–>Show View–>Navigator,然后打开项目
的.settings目录 -->org.eclipse.wst.common.project.facet.core.xml文件,把java改为1.7,
把java.web改为2.5,如下图所示:
打开项目属性(Properties)–>Java Build Path查看缺失目录然后补全,如下图:
补全后如下图:
修改pom.xml(一级目录下最后一个文件)以SSM框架包为例修改,修改代码如下:
<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.0modelVersion>
<groupId>com.gxgroupId>
<artifactId>BookManagementartifactId>
<packaging>warpackaging>
<version>0.0.1-SNAPSHOTversion>
<name>BookManagement Maven Webappname>
<url>http://maven.apache.orgurl>
<properties>
<spring.version>3.2.4.RELEASEspring.version>
<mybatis.version>3.2.4mybatis.version>
<slf4j.version>1.6.6slf4j.version>
<log4j.version>1.2.17log4j.version>
<fastjson.version>1.1.33fastjson.version>
<commons-codec.version>1.6commons-codec.version>
<commons-lang.version>2.5commons-lang.version>
<project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
properties>
<dependencies>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-coreartifactId>
<version>${spring.version}version>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-webartifactId>
<version>${spring.version}version>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-oxmartifactId>
<version>${spring.version}version>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-txartifactId>
<version>${spring.version}version>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-webmvcartifactId>
<version>${spring.version}version>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-aopartifactId>
<version>${spring.version}version>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-jdbcartifactId>
<version>${spring.version}version>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-context-supportartifactId>
<version>${spring.version}version>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-testartifactId>
<version>${spring.version}version>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-aspectsartifactId>
<version>${spring.version}version>
dependency>
<dependency>
<groupId>org.mybatisgroupId>
<artifactId>mybatisartifactId>
<version>${mybatis.version}version>
dependency>
<dependency>
<groupId>org.mybatisgroupId>
<artifactId>mybatis-springartifactId>
<version>1.2.2version>
dependency>
<dependency>
<groupId>mysqlgroupId>
<artifactId>mysql-connector-javaartifactId>
<version>5.1.22version>
dependency>
<dependency>
<groupId>junitgroupId>
<artifactId>junitartifactId>
<version>4.11version>
<scope>testscope>
dependency>
<dependency>
<groupId>com.alibabagroupId>
<artifactId>druidartifactId>
<version>1.0.2version>
dependency>
<dependency>
<groupId>com.alibabagroupId>
<artifactId>fastjsonartifactId>
<version>${fastjson.version}version>
dependency>
<dependency>
<groupId>org.codehaus.jacksongroupId>
<artifactId>jackson-mapper-aslartifactId>
<version>1.9.13version>
dependency>
<dependency>
<groupId>com.google.code.gsongroupId>
<artifactId>gsonartifactId>
<version>2.8.0version>
dependency>
<dependency>
<groupId>net.sf.json-libgroupId>
<artifactId>json-libartifactId>
<version>2.4version>
<classifier>jdk15classifier>
dependency>
<dependency>
<groupId>commons-fileuploadgroupId>
<artifactId>commons-fileuploadartifactId>
<version>1.3.1version>
dependency>
<dependency>
<groupId>commons-langgroupId>
<artifactId>commons-langartifactId>
<version>${commons-lang.version}version>
dependency>
<dependency>
<groupId>org.apache.commonsgroupId>
<artifactId>commons-lang3artifactId>
<version>3.4version>
dependency>
<dependency>
<groupId>commons-codecgroupId>
<artifactId>commons-codecartifactId>
<version>${commons-codec.version}version>
dependency>
<dependency>
<groupId>javax.servletgroupId>
<artifactId>jstlartifactId>
<version>1.2version>
<scope>runtimescope>
dependency>
<dependency>
<groupId>javax.servletgroupId>
<artifactId>servlet-apiartifactId>
<version>2.5version>
<scope>providedscope>
dependency>
<dependency>
<groupId>javax.servlet.jspgroupId>
<artifactId>jsp-apiartifactId>
<version>2.0version>
<scope>providedscope>
dependency>
!-- 日志文件管理包 -->
!-- log start -->
<dependency>
<groupId>log4jgroupId>
<artifactId>log4jartifactId>
<version>${log4j.version}version>
dependency>
<dependency>
<groupId>org.slf4jgroupId>
<artifactId>slf4j-apiartifactId>
<version>${slf4j.version}version>
dependency>
<dependency>
<groupId>org.slf4jgroupId>
<artifactId>slf4j-log4j12artifactId>
<version>${slf4j.version}version>
dependency>
<dependency>
<groupId>org.freemarkergroupId>
<artifactId>freemarkerartifactId>
<version>2.3.22version>
dependency>
<dependency>
<groupId>jsptagsgroupId>
<artifactId>pager-taglibartifactId>
<version>2.0version>
dependency>
<dependency>
<groupId>javax.mailgroupId>
<artifactId>mailartifactId>
<version>1.4version>
dependency>
<dependency>
<groupId>net.sf.ehcachegroupId>
<artifactId>ehcacheartifactId>
<version>2.9.1version>
dependency>
dependencies>
<build>
<finalName>BookManagementfinalName>
<plugins>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven‐compiler-pluginartifactId>
<version>2.3.2version>
<configuration>
<source>1.7source>
<target>1.7target>
configuration>
plugin>
plugins>
build>
project>