写点什么

SSM 最简单最全面的整合 Spring+SpringMVC+Mybatis 三大框架 快速搭建

  • 2022 年 4 月 15 日
  • 本文字数:5716 字

    阅读完需:约 19 分钟

<version>${spring.version}</version>


</dependency>


<dependency>


<groupId>org.springframework</groupId>


<artifactId>spring-test</artifactId>


<version>${spring.version}</version>


</dependency>


<dependency>


<groupId>org.mybatis</groupId>


<artifactId>mybatis</artifactId>


<version>${mybatis.version}</version>


</dependency>


<dependency>


<groupId>org.mybatis</groupId>


<artifactId>mybatis-spring</artifactId>


<version>1.2.2</version>


</dependency>


<dependency>


<groupId>org.mybatis.generator</groupId>


<artifactId>mybatis-generator-core</artifactId>


<version>1.3.5</version>


</dependency>


<dependency>


<groupId>mysql</groupId>


<artifactId>mysql-connector-java</artifactId>


<version>5.1.29</version>


</dependency>


<dependency>


<groupId>junit</groupId>


<artifactId>junit</artifactId>


<version>4.11</version>


<scope>test</scope>


</dependency>


<dependency>


<groupId>javax.servlet</groupId>


<artifactId>jstl</artifactId>


<version>1.2</version>


</dependency>


<dependency>


<groupId>javax.servlet.jsp</groupId>


<artifactId>jsp-api</artifactId>


<version>2.2.1-b03</version>


<scope>provided</scope>


</dependency>


<dependency>


<groupId>javax.servlet</groupId>


<artifactId>servlet-api</artifactId>


<version>2.5</version>


<scope>provided</scope>


</dependency>


<dependency>


<groupId>com.fasterxml.jackson.core</groupId>


<artifactId>jackson-core</artifactId>


<version>2.7.1</version>


</dependency>


<dependency>


<groupId>com.fasterxml.jackson.core</groupId>


<artifactId>jackson-annotations</artifactId>


<version>2.7.1</version>


</dependency>


<dependency>


<groupId>com.fasterxml.jackson.core</groupId>


<artifactId>jackson-databind</artifactId>


<version>2.7.1</version>


</dependency>


<dependency>


<groupId>net.sf.json-lib</groupId>


<artifactId>json-lib</artifactId>


<version>2.4</version>


<classifier>jdk15</classifier>


</dependency>


<dependency>


<groupId>commons-lang</groupId>


<artifactId>commons-lang</artifactId>


<version>2.4</version>


</dependency>


<dependency>


<groupId>commons-logging</groupId>


<artifactId>commons-logging</artifactId>


<version>1.1</version>


</dependency>


<dependency>


<groupId>commons-pool</groupId>


<artifactId>commons-pool</artifactId>


<version>1.5.6</version>


</dependency>


<dependency>


<groupId>commons-dbcp</groupId>


<artifactId>commons-dbcp</artifactId>


<version>1.4</version>


</dependency>


<dependency>


<groupId>commons-beanutils</groupId>


<artifactId>commons-beanutils</artifactId>


<version>1.8.3</version>


</dependency>


<dependency>


<groupId>commons-httpclient</groupId>


<artifactId>commons-httpclient</artifactId>


<version>3.1</version>


</dependency>


<dependency>


<groupId>commons-collections</groupId>


<artifactId>commons-collections</artifactId>


<version>3.1</version>


</dependency>


<dependency>


<groupId>commons-codec</groupId>


<artifactId>commons-codec</artifactId>


<version>1.9</version>


</dependency>


<dependency>


<groupId>javax.annotation</groupId>


<artifactId>jsr250-api</artifactId>


<version>1.0</version>


</dependency>


<dependency>


<groupId>net.sf.ezmorph</groupId>


<artifactId>ezmorph</artifactId>


<version>1.0.6</version>


</dependency>


<dependency>


<groupId>javax.activation</groupId>


<artifactId>activation</artifactId>


<version>1.1</version>


</dependency>


<dependency>


<groupId>taglibs</groupId>


<artifactId>standard</artifactId>


<version>1.1.2</version>


</dependency>


<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>


<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>


</dependencies>


<build>


<finalName>elegantjc</finalName>


<plugins>


<plugin>


<artifactId>maven-clean-plugin</artifactId>


<version>3.1.0</version>


</plugin>


<plugin>


<artifactId>maven-resources-plugin</artifactId>


<version>3.0.2</version>


</plugin>


<plugin>


<artifactId>maven-compiler-plugin</artifactId>


<version>3.8.0</version>


</plugin>


<plugin>


<artifactId>maven-surefire-plugin</artifactId>


<version>2.22.1</version>


</plugin>


<plugin>


<artifactId>maven-war-plugin</artifactId>


<version>3.2.2</version>


</plugin>


<plugin>


<artifactId>maven-install-plugin</artifactId>


<version>2.5.2</version>


</plugin>


<plugin>


<artifactId>maven-deploy-plugin</artifactId>


<version>2.8.2</version>


</plugin>


</plugins>


</pluginManagement>


<plugins>


<plugin>


<groupId>org.mybatis.generator</groupId>


<artifactId>mybatis-generator-maven-plugin</artifactId>


<version>1.3.2</version>


<configuration>


<verbose>true</verbose>


<overwrite>true</overwrite>


</configuration>


</plugin>


</plugins>


</build>


</project>


然后 jdbc.properties:


driver=com.mysql.jdbc.Driver


#game_message 为我本地的数据库名


url=jdbc:mysql://localhost:3306/game_message?useUnicode=true&characterEncoding=utf-8


username=root


#下面输入自己数据库的密码


password=root


#定义初始连接数


initialSize=0


#定义最大连接数


maxActive=20


#定义最大空闲


maxIdle=20


#定义最小空闲


minIdle=1


#定义最长等待时间


maxWait=60000


然后 log4j.properties:


#log4j.rootLogger=debug,console,debug,info,warn,error,fatal


log4j.rootLogger=INFO,info,warn,error,fatal


log4j.appender.console=org.apache.log4j.ConsoleAppender


log4j.appender.console.layout=org.apache.log4j.PatternLayout


log4j.appender.console.Encoding=UTF-8


log4j.appender.console.layout.ConversionPattern= %p %d{MM-dd_HH:mm:ss} %F %L %m %n


#log4j.logger.java.sql.ResultSet=INFO


#log4j.logger.org.apache=INFO


#log4j.logger.java.sql.Connection=INFO


#log4j.logger.java.sql.Statement=DEBUG


log4j.logger.java.sql.ResultSet=INFO


log4j.logger.org.apache=INFO


log4j.logger.java.sql.Connection=DEBUG


log4j.logger.java.sql.Statement=DEBUG


log4j.logger.java.sql.PreparedStatement=DEBUG


log4j.logger.org.springframework=ERROR


log4j.logger.org.mybatis=ERROR


log4j.logger.org.hibernate=ERRO Java 开源项目【ali1024.coding.net/public/P7/Java/git】 R


log4j.logger.com.mchange=ERROR


log4j.logger.org.quartz=ERROR


log4j.logger.debug=debug


log4j.appender.debug=org.apache.log4j.DailyRollingFileAppender


log4j.appender.debug.layout=org.apache.log4j.PatternLayout


log4j.appender.debug.layout.ConversionPattern= %p %d{MM-dd_HH:mm:ss} %F %L %m %n


log4j.appender.debug.datePattern='.'yyyy-MM-dd-HH


log4j.appender.debug.Threshold=DEBUG


log4j.appender.debug.append=true


log4j.appender.debug.Encoding=UTF-8


log4j.appender.debug.File=${loghome}/mall_debug.log


log4j.logger.info=info


log4j.appender.info=org.apache.log4j.DailyRollingFileAppender


log4j.appender.info.layout=org.apache.log4j.PatternLayout


log4j.appender.info.layout.ConversionPattern= %p %d{MM-dd_HH:mm:ss} %F %L %m %n


log4j.appender.info.datePattern='.'yyyy-MM-dd-HH


log4j.appender.info.Threshold=INFO


log4j.appender.info.append=true


log4j.appender.info.Encoding=UTF-8


log4j.appender.info.File=${loghome}/mall_info.log


log4j.logger.warn=warn


log4j.appender.warn=org.apache.log4j.DailyRollingFileAppender


log4j.appender.warn.layout=org.apache.log4j.PatternLayout


log4j.appender.warn.layout.ConversionPattern= %p %d{MM-dd_HH:mm:ss} %F %L %m %n


log4j.appender.warn.datePattern='.'yyyy-MM-dd-HH


log4j.appender.warn.Threshold=WARN


log4j.appender.warn.append=true


log4j.appender.warn.Encoding=UTF-8


log4j.appender.warn.File=${loghome}/mall_warn.log


log4j.logger.error=error


log4j.appender.error=org.apache.log4j.DailyRollingFileAppender


log4j.appender.error.layout=org.apache.log4j.PatternLayout


log4j.appender.error.layout.ConversionPattern= %p %d{MM-dd_HH:mm:ss} %F %L %m %n


log4j.appender.error.datePattern='.'yyyy-MM-dd-HH


log4j.appender.error.Threshold=ERROR


log4j.appender.error.append=true


log4j.appender.error.Encoding=UTF-8


log4j.appender.error.File=${loghome}/mall_error.log


log4j.logger.fatal=fatal


log4j.appender.fatal=org.apache.log4j.DailyRollingFileAppender


log4j.appender.fatal.layout=org.apache.log4j.PatternLayout


log4j.appender.fatal.layout.ConversionPattern= %p %d{MM-dd_HH:mm:ss} %F %L %m %n


log4j.appender.fatal.datePattern='.'yyyy-MM-dd-HH


log4j.appender.fatal.Threshold=FATAL


log4j.appender.fa 《一线大厂 Java 面试题解析+后端开发学习笔记+最新架构讲解视频+实战项目源码讲义》开源 tal.append=true


log4j.appender.fatal.Encoding=UTF-8


log4j.appender.fatal.File=${loghome}/mall_fatal.log


#The log output to the directory


#loghome=/log/tomcat/zqgameapi_logs


#loghome=/data/logs/tomcat/admin.gamelaoyou.com


loghome=F:\log_data


mybatis.xml:


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


<!DOCTYPE configuration


PUBLIC "-//mybatis.org//DTD Config 3.0//EN"


"http://mybatis.org/dtd/mybatis-3-config.dtd">


<configuration>


<settings>


<setting name="cacheEnabled" value="false" />


<setting name="useGeneratedKeys" value="true" />


<setting name="defaultExecutorType" value="REUSE" />


<setting name="logImpl" value="STDOUT_LOGGING" />


</settings>


</configuration>


applicationContext.xml:


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


<beans xmlns="http://www.springframework.org/schema/beans"


xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"


xmlns:context="http://www.springframework.org/schema/context"


xmlns:beans="http://www.springframework.org/schema/beans"


xmlns:mvc="http://www.springframework.org/schema/mvc"


xsi:schemaLocation="http://www.springframework.org/schema/beans


http://www.springframework.org/schema/beans/spring-beans-4.3.xsd


http://www.springframework.org/schema/context


http://www.springframework.org/schema/context/spring-context-4.3.xsd


http://www.springframework.org/schema/mvc


http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd" >


<context:component-scan base-package="com.springmvc"/>


<mvc:annotation-driven />


<mvc:resources location="/images/" mapping="/images/**"/>


<mvc:resources location="/css/" mapping="/css/**"/>


<mvc:resources location="/styles/" mapping="/styles/**"/>


<mvc:resources location="/js/" mapping="/js/**"/>


<!-- Configures the @Controller programming model


<mvc:annotation-driven />-->


<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">


<property name="messageConverters">


<list>


<ref bean="mappingJacksonHttpMessageConverter"/>


</list>


</property>


</bean>


<bean id="mappingJacksonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">


<property name="supportedMediaTypes">


<list>


<value>application/json;charset=UTF-8</value>


</list>


</property>


</bean>


<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">


<property name="dataSource" ref="dataSource"/>


<property name="configLocation" value="classpath:mybatis.xml" />


<property name="mapperLocations" value="classpath:sqlmap/*Mapper.xml"/>


<property name="typeAliasesPackage" value="com.springmvc.entity" />


</bean>


<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">


<property name="basePackage" value="com.springmvc.dao"/>


<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>


</bean>


<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">


<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>


<property name="prefix" value="/WEB-INF/views/" />


<property name="suffix" value=".jsp" />


</bean>

最后希望可以帮助到大家!

千千万万要记得:多刷题!!多刷题!!


之前算法是我的硬伤,后面硬啃了好长一段时间才补回来,算法才是程序员的灵魂!!!!


篇幅有限,以下只能截图分享部分的资源!!


(1)多线程(这里以多线程为代表,其实整理了一本 JAVA 核心架构笔记集)



(2)刷的算法题(还有左神的算法笔记)



(3)面经+真题解析+对应的相关笔记(很全面)



(4)视频学习(部分)


ps:当你觉得学不进或者累了的时候,视频是个不错的选择


在这里,最后只一句话:祝大家 offer 拿到手软!!

用户头像

还未添加个人签名 2022.04.13 加入

还未添加个人简介

评论

发布
暂无评论
SSM  最简单最全面的整合Spring+SpringMVC+Mybatis三大框架 快速搭建_Java_爱好编程进阶_InfoQ写作平台