maven项目配置(以及引入SSM框架的相关jar包)

一.Maven配置

1.maven框架的settings.xml文件配置

 

 

E:/reop

 

 

 

      mirrorId

      repositoryId

      Human Readable Name for this Mirror.

      http://my.repository.com/repo/path

    

2.maven框架的pom.xml文件配置

2-1maven-compiler-plugin 配置

maven-compiler-plugin配置的作用

1.maven是项目管理工具,如果我们代码使用的JDK版本不告诉maven,则maven会使用默认的JDK版本,这样可能默认的JDK版本与我们使用的版本不一致会造成版本冲突,导致maven项目的代码编译失败

<plugins>

<plugin

<groupId>org.apache.maven.pluginsgroupId>

<artifactId>maven-compiler-pluginartifactId>

<version>3.7.0version>

<configuration>

<source>1.8source>

<target>1.8target>

<encoding>UTF8encoding>

configuration>

plugin>

plugins>

2-2引入项目所需要的jar

2-2-1引入spring相关jar

一、

<properties>

<spring.version>5.0.1.RELEASEspring.version>

properties> 

二、

<dependency>

<groupId>org.springframeworkgroupId>

<artifactId>spring-coreartifactId>

<version>${spring.version}version>

dependency>

<dependency>

<groupId>org.springframeworkgroupId>

<artifactId>spring-beansartifactId>

<version>${spring.version}version>

dependency>

<dependency>

<groupId>org.springframeworkgroupId>

<artifactId>spring-contextartifactId>

<version>${spring.version}version>

dependency>

<dependency>

<groupId>org.springframeworkgroupId>

<artifactId>spring-jdbcartifactId>

<version>${spring.version}version>

dependency>

<dependency>

<groupId>org.springframeworkgroupId>

<artifactId>spring-txartifactId>

<version>${spring.version}version>

dependency>

<dependency>

<groupId>org.springframeworkgroupId>

<artifactId>spring-webartifactId>

<version>${spring.version}version>

dependency>

<dependency>

<groupId>org.springframeworkgroupId>

<artifactId>spring-webmvcartifactId>

<version>${spring.version}version>

dependency>

<dependency>

<groupId>org.springframeworkgroupId>

<artifactId>spring-testartifactId>

<version>${spring.version}version>

<scope>testscope>

dependency>

2-2-2引入servlet webjackson、commons相关jar

2.2.2.1servlet web相关jar

<dependency>

    <groupId>javax.servletgroupId>

    <artifactId>javax.servlet-apiartifactId>

    <version>4.0.0version>

    <scope>providedscope>

dependency>

 

2.2.2.2Jackson相关jar

<dependency>

    <groupId>com.fasterxml.jackson.coregroupId>

    <artifactId>jackson-databindartifactId>

    <version>2.9.2version>

dependency>

2.2.2.3Commons相关jar

<dependency>

    <groupId>commons-collectionsgroupId>

    <artifactId>commons-collectionsartifactId>

    <version>3.2.2version>

dependency>

2-2-3引入mybatis相关jar

<dependency>

    <groupId>org.mybatisgroupId>

    <artifactId>mybatisartifactId>

    <version>3.4.5version>

dependency>

<dependency>

    <groupId>org.mybatisgroupId>

    <artifactId>mybatis-springartifactId>

    <version>1.3.1version>

dependency>

2-2-4引入数据库相关jar

<dependency>

    <groupId>mysqlgroupId>

    <artifactId>mysql-connector-javaartifactId>

    <version>6.0.6version>

dependency>

<dependency>

    <groupId>c3p0groupId>

    <artifactId>c3p0artifactId>

    <version>0.9.2version>

dependency>

3.web.xml配置

3-1更改web版本步骤

3-1-1Web版本3.1头部声明

xml version="1.0" encoding="UTF-8"?>

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" 

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee                      http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"

version="3.1" metadata-complete="true">

  <display-name>Archetype Created Web Applicationdisplay-name>

web-app>

  

  <welcome-file-list>

  <welcome-file>index.jspwelcome-file>

  welcome-file-list>

3-2spring配置文件进行整合

 

  <servlet>

  <servlet-name>spring-dispatcherservlet-name>

<servlet-class>org.springframework.web.servlet.DispatcherServletservlet-class>

  

  

  <init-param>

  <param-name>contextConfigLocationparam-name>

<param-value>classpath:spring/spring-*.xmlparam-value>

  init-param>

  servlet> 

  <servlet-mapping>

  <servlet-name>spring-dispatcherservlet-name>

  

  <url-pattern>/url-pattern>

  servlet-mapping>

4. 数据库连接文件jdbc.properties

jdbc.driver=com.mysql.jdbc.Driver

jdbc.url=jdbc:mysql://localhost:3306/o2o?useUnicode=true&characterEncoding=utf8

jdbc.username=数据库用户名

jdbc.password=数据库密码

 个人原创,若需转载,请注明出处!!!

你可能感兴趣的:(SSM框架配置,Maven配置)