欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

使用IDEA配置Maven搭建开发框架ssm教程

程序员文章站 2023-12-02 23:03:46
一、配置maven环境 1.下载maven 下载链接 2.下载完成解压压缩包并创建本地仓库文件夹 3.打开解压缩文件,配置本地仓库路径 4.配置m...

一、配置maven环境

1.下载maven

下载链接

使用IDEA配置Maven搭建开发框架ssm教程

2.下载完成解压压缩包并创建本地仓库文件夹

使用IDEA配置Maven搭建开发框架ssm教程

3.打开解压缩文件,配置本地仓库路径

使用IDEA配置Maven搭建开发框架ssm教程

使用IDEA配置Maven搭建开发框架ssm教程

4.配置maven环境变量

使用IDEA配置Maven搭建开发框架ssm教程

使用IDEA配置Maven搭建开发框架ssm教程

使用IDEA配置Maven搭建开发框架ssm教程

使用IDEA配置Maven搭建开发框架ssm教程

5.在cmd中查看maven是否配置正确

在cmd中输入mvn -v命令查看

使用IDEA配置Maven搭建开发框架ssm教程

二、在intellij idea中配置maven

打开-file-settings

使用IDEA配置Maven搭建开发框架ssm教程

三、新建maven javaweb项目

1.打开-file-new-project

使用IDEA配置Maven搭建开发框架ssm教程

next

使用IDEA配置Maven搭建开发框架ssm教程

next

添加的配置为 archetypecatalog=internal

使用IDEA配置Maven搭建开发框架ssm教程

next

使用IDEA配置Maven搭建开发框架ssm教程

点击finish完成

生成项目框架后,在 src/main 下创建 java目录。项目的工程结构如图。

使用IDEA配置Maven搭建开发框架ssm教程

四、配置项目框架文件

<?xml version="1.0" encoding="utf-8"?>
<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.cwp</groupid>
 <artifactid>ssmdemo01</artifactid>
 <version>1.0-snapshot</version>
 <url>http://maven.apache.org</url>
 <properties>
 <project.build.sourceencoding>utf-8</project.build.sourceencoding>
 <project.reporting.outputencoding>utf-8</project.reporting.outputencoding>

 <!-- spring版本号 -->
 <spring.version>4.2.5.release</spring.version>

 <!-- mybatis版本号 -->
 <mybatis.version>3.2.8</mybatis.version>

 <!-- mysql驱动版本号 -->
 <mysql-driver.version>5.1.29</mysql-driver.version>

 <!-- log4j日志包版本号 -->
 <slf4j.version>1.7.18</slf4j.version>
 <log4j.version>1.2.17</log4j.version>

 </properties>


 <dependencies>
 <!-- 添加jstl依赖 -->
 <dependency>
  <groupid>jstl</groupid>
  <artifactid>jstl</artifactid>
  <version>1.2</version>
 </dependency>

 <dependency>
  <groupid>javax</groupid>
  <artifactid>javaee-api</artifactid>
  <version>7.0</version>
 </dependency>

 <!-- 添加junit4依赖 -->
 <dependency>
  <groupid>junit</groupid>
  <artifactid>junit</artifactid>
  <version>4.11</version>
  <!-- 指定范围,在测试时才会加载 -->
  <scope>test</scope>
 </dependency>

 <!-- 添加spring核心依赖 -->
 <dependency>
  <groupid>org.springframework</groupid>
  <artifactid>spring-core</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-oxm</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-jdbc</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-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-aop</artifactid>
  <version>${spring.version}</version>
 </dependency>

 <dependency>
  <groupid>org.springframework</groupid>
  <artifactid>spring-test</artifactid>
  <version>${spring.version}</version>
 </dependency>

 <!-- 添加mybatis依赖 -->
 <dependency>
  <groupid>org.mybatis</groupid>
  <artifactid>mybatis</artifactid>
  <version>${mybatis.version}</version>
 </dependency>

 <!-- 添加mybatis/spring整合包依赖 -->
 <dependency>
  <groupid>org.mybatis</groupid>
  <artifactid>mybatis-spring</artifactid>
  <version>1.2.2</version>
 </dependency>

 <!-- 添加mysql驱动依赖 -->
 <dependency>
  <groupid>mysql</groupid>
  <artifactid>mysql-connector-java</artifactid>
  <version>${mysql-driver.version}</version>
 </dependency>
 <!-- 添加数据库连接池依赖 -->
 <dependency>
  <groupid>commons-dbcp</groupid>
  <artifactid>commons-dbcp</artifactid>
  <version>1.2.2</version>
 </dependency>

 <!-- 添加fastjson -->
 <dependency>
  <groupid>com.alibaba</groupid>
  <artifactid>fastjson</artifactid>
  <version>1.1.41</version>
 </dependency>

 <!-- 添加日志相关jar包 -->
 <dependency>
  <groupid>log4j</groupid>
  <artifactid>log4j</artifactid>
  <version>${log4j.version}</version>
 </dependency>
 <dependency>
  <groupid>org.slf4j</groupid>
  <artifactid>slf4j-api</artifactid>
  <version>${slf4j.version}</version>
 </dependency>
 <dependency>
  <groupid>org.slf4j</groupid>
  <artifactid>slf4j-log4j12</artifactid>
  <version>${slf4j.version}</version>
 </dependency>

 <!-- log end -->
 <!-- 映入json -->
 <dependency>
  <groupid>org.codehaus.jackson</groupid>
  <artifactid>jackson-mapper-asl</artifactid>
  <version>1.9.13</version>
 </dependency>
 <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
 <dependency>
  <groupid>com.fasterxml.jackson.core</groupid>
  <artifactid>jackson-core</artifactid>
  <version>2.8.0</version>
 </dependency>
 <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
 <dependency>
  <groupid>com.fasterxml.jackson.core</groupid>
  <artifactid>jackson-databind</artifactid>
  <version>2.8.0</version>
 </dependency>

 <dependency>
  <groupid>commons-fileupload</groupid>
  <artifactid>commons-fileupload</artifactid>
  <version>1.3.1</version>
 </dependency>

 <dependency>
  <groupid>commons-io</groupid>
  <artifactid>commons-io</artifactid>
  <version>2.4</version>
 </dependency>

 <dependency>
  <groupid>commons-codec</groupid>
  <artifactid>commons-codec</artifactid>
  <version>1.9</version>
 </dependency>
 </dependencies>

 <build>
 <finalname>web-ssm</finalname>
 </build>

</project>

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。