Maven工程基础配置(SSM框架)
1.创建Maven工程技术:基础框架-ssm(SpringMVC+Spring+MyBatis)数据库-MySQL前端框架-BootStrap项目的依赖管理-Maven分页-pagehelper逆向工程-MyBatis Generator基础环境搭建Maven工程创建Eclipse参照Eclipse中创建Maven版的Web工程Myec
·
1.创建Maven工程
技术:
- 基础框架-ssm(SpringMVC+Spring+MyBatis)
- 数据库-MySQL
- 前端框架-BootStrap
- 项目的依赖管理-Maven
- 分页-pagehelper
- 逆向工程-MyBatis Generator
基础环境搭建
Maven工程创建
Eclipse参照Eclipse中创建Maven版的Web工程
Myeclipse参照使用myeclipse建立maven项目
如果跟据上述创建仍出现错误找到.m2\repository文件删除其下所有文件然后更新你的maven工程(出现错误尝试删除旗下某些或全部文件并更新亲测可行)
对Maven的setting.xml进行配置
在Preferences的Maven的User Settings下找到settings.xml路径并打开
在< mirrors >标签下加入(使用阿里云的镜像仓库)
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</mirror>
在< profiles >标签下加入(填入对应的jdk版本)
<profile>
<id>jdk-1.8</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile>
引入依赖jar包
在pom.xml中引入依赖
进入Maven中央仓库https://mvnrepository.com
搜索你所需要引入的模块及其对应版本,复制代码于pom.xml中maven工程会自动下载对应jar包
这里给出Myeclipse下的一个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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.guigu</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<webVersion>3.0</webVersion>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
<!-- 引入项目依赖的jar包-->
<!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.3.7.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-jdbc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>4.3.7.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-aspects 面向切面编程-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<version>4.3.7.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mybatis/mybatis -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.4.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mybatis/mybatis-spring 适配包-->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.3.1</version>
</dependency>
<!-- 数据库链接池,驱动 -->
<!-- https://mvnrepository.com/artifact/c3p0/c3p0 数据库链接池-->
<dependency>
<groupId>c3p0</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.41</version>
</dependency>
<!-- jstl,servlet-api,junit -->
<!-- https://mvnrepository.com/artifact/jstl/jstl -->
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mortbay.jetty/servlet-api -->
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>servlet-api</artifactId>
<version>3.0.20100224</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
更多推荐
所有评论(0)