Spring+Mybatis+Velocity整合(1):建立一个Maven项目
2017-07-09 00:00
507 查看
一、maven简介以及常用概念
1.Maven是一个项目管理和整合的工具。Maven为开发者提供了一套完整的构建生命周期框架。开发团队基本不用花多少时间就能自动完成工程的基础构建配置,因为Maven使用了一个标准的目录结构和一个默认的构建生命周期。在创建报告、检查、构建和测试自动配置时,Maven可以让开发者的工作变得更简单。maven可以做的事: 构建、文档生成、报告、依赖、 SCMs(software configuration Management)、发布、分发 、邮件列表。
Maven使用约定而不是配置,意味着开发者不需要再自己创建构建过程。当创建Maven工程时,Maven会创建默认的工程结构,开发者只需要合理的放置配置文件而在pom.xml中无需做任何配置。
2.首先分享一个maven中央仓库: http://www.mvnrepository.com/
进入之后,搜索你要的jar包名,从相应的版本进入,把pom依赖复制到项目的pom.xml文件,重新mvn eclipse:eclipse就可以自动下载回依赖包了,很方便
3.常用概念
groupId:组织名称,举个例子,比如spring项目,它的groupId是 org.springframework,这是一个唯一的名称,用来形容整个项目。
artifactId:具体项目名称,比如spring项目,的一个bean子项目的artifactId是spring-beans
version:版本号
二、用IDEA创建maven项目
可以参考我之前的一篇文章,如何用IDEA创建空白的Maven项目,下面是传送门:https://my.oschina.net/nicekk/blog/1236243
修改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/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.jczj123</groupId> <artifactId>Test3</artifactId> <packaging>war</packaging> <version>0.0.1-SNAPSHOT</version> <name>ebuy Maven Webapp</name> <url>http://maven.apache.org</url> <properties> <!-- spring --> <spring.version>4.1.7.RELEASE</spring.version> <!-- junit --> <junit.version>4.12</junit.version> <!-- MyBatis --> <mybatis.version>3.3.0</mybatis.version> <mybaitsSpring.version>1.2.3</mybaitsSpring.version> <!-- 连接mysql --> <mysqlConnec.version>5.1.36</mysqlConnec.version> <!-- log4j --> <log4j.version>1.2.17</log4j.version> <!-- velocity --> <velocity.version>1.7</velocity.version> <velocityTools.version>2.0</velocityTools.version> <!--Druid 连接池--> <druid.version>1.1.0</druid.version> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>${junit.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>${mybatis.version}</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>${mysqlConnec.version}</version> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>${log4j.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-tx</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aspects</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> <version>${mybaitsSpring.version}</version> </dependency> <!-- 添加servlet支持 --> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version> </dependency> <dependency> <groupId>org.apache.velocity</groupId> <artifactId>velocity-tools</artifactId> <version>${velocityTools.version}</version> </dependency> <!-- https://mvnrepository.com/artifact/com.alibaba/druid --> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>${druid.version}</version> </dependency> <dependency> <groupId>org.apache.velocity</groupId> <artifactId>velocity</artifactId> <version>${velocity.version}</version> </dependency> </dependencies> <build> <finalName>Test3</finalName> </build> </project>
相关文章推荐
- 第一章 企业项目开发--maven+springmvc+spring+mybatis+velocity整合
- maven项目,在spring中整合mybatis
- 《Lucene、webservice、(svn_ant_maven)、DWR、Freemarker、POI视频教程》更新了Spring、JAXWs的整合并且完成了一个小项目
- Springmvc+Mybatis+Velocity实现小demo(Maven项目)
- 创建一个Spring+SpringMVC+MyBatis+MySql+Maven项目需要注意的地方
- 使用Idea创建ssm项目,SpringMVC+Spring+MyBatis+Maven整合
- Maven 工程整合 Spring mvc + Mybatis +Velocity
- IntelliJ IDEA下SSM框架整合、创建Maven项目流程(Spring + SpringMVC + MyBatis)
- idea建立一个maven新项目的设置和整合tomcat
- Maven项目中Spring整合Mybatis
- springmvc+mybatis+maven项目集成的时候遇到一个问题,项目搭起来以后,http请求怎么都进不到controller中,页面直接返回404错误,控制台没有报任何错误,请大神帮我看看
- velocity mybatis spring 在maven的整合开发(四)
- velocity mybatis spring 在maven的整合开发(三)
- 使用Idea创建ssm项目,SpringMVC+Spring+MyBatis+Maven整合
- 利用Intellij+MAVEN完成Spring整合Mybatis项目详解
- Spring MVC+Mybatis+Maven+Velocity+Mysql整合实例
- 05(maven+SSH)网上商城项目实战之spring mybatis整合
- Spring MVC+Mybatis+Maven+Velocity+Mysql整合实例
- Spring+SpringMVC+Mybatis整合系列(二)Eclipse新建Maven web项目
- maven+springMVC+mybatis+velocity+mysql+junit项目框架搭建