spring各个配置文件模板,持续更新

pom.xml

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!--spring 版本 -->
<spring.version>4.3.14.RELEASE</spring.version>
<!--mysql连接器版本 -->
<mysql.version>6.0.6</mysql.version>
</properties>

<dependencies>
<!--junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<!--log -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<!-- 通用日志模块,如果不用log4j就用这个
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
-->
<!--spring 包含20个组件, 其中组件要运行需要log的支持-->
<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-beans</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-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-instrument</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-instrument-tomcat</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-jms</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-messaging</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</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-test</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-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-webmvc-portlet</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-websocket</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- aop支持,除了基础的spring aop外还需要以下几个 -->
<dependency>
<groupId>aopalliance</groupId>
<artifactId>aopalliance</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.8.10</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.8.10</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.8.10</version>
</dependency>
<!-- jdbc驱动 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.15</version>
</dependency>
<!-- mybatis -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.3.0</version>
</dependency>
<!-- json -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.4</version>
</dependency>
</dependencies>

<!-- maven工程采用的jdk版本 -->
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<!-- maven版本号 -->
<version>3.6.0</version>

<!-- jdk版本号 -->
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>

jdbc.properties

jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/example?characterEncoding=utf-8
jdbc.username=数据库用户名
jdbc.password=数据库密码

mybatis-config.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>

<!-- 引入数据源配置文件 -->
<properties resource="jdbc.properties" />
<!-- 为了避免一直编写包全名,定义别名以方便引用类 -->
<typeAliases>
<typeAlias type="package.class" alias="alias"/>
</typeAliases>

<!-- 定义数据库环境,且默认使用development环境 -->
<environments default="development">
<!-- 定义id为development的数据库环境, 数据库环境可以定义多个 -->
<environment id="development">
<!-- 采用jdbc事务管理 -->
<transactionManager type="JDBC"/>
<!-- 配置数据库连接信息 -->
<dataSource type="POOLED">
<property name="driver" value="${jdbc.driver}"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
</dataSource>
</environment>
</environments>
<!-- 定义映射器 -->
<mappers>
<!-- 引入AdminMapper映射器配置文件 -->
<!--mapper resource="com/hao/example/mapper/AdminMapper.xml"/-->
</mappers>

</configuration>

mapper.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hao.example.mapper.AdminMapper">
<select id="getAdmin" resultType="admin" parameterType="int">
select * from admin where id = #{id}
</select>
<insert id="insertAdmin" parameterType="admin">
insert into admin(username, password) values(#{username}, #{password})
</insert>
<delete id="deleteAdmin" parameterType="int">
delete from admin where id = #{id}
</delete>
</mapper>

原文地址:https://www.cnblogs.com/hjwc/p/10391636.html

时间: 2024-10-05 05:05:03

spring各个配置文件模板,持续更新的相关文章

spring hibernate 配置文件模板

<?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/sch

spring学习笔记(持续更新)

1. spring替我们创建的bean,它放在哪里了? 通常而言,我们一般会用到两种bean:singleton和prototype.对于singleton的bean,一旦创建过后,spring会把它存到一个map里面. DefaultSingletonBeanRegistry类 /** Cache of singleton objects: bean name --> bean instance */private final Map<String, Object> singleton

[模板][持续更新]欧拉回路与欧拉路径浅析

Luogu P2731 骑马修栅栏 Riding the Fences 题目背景 Farmer John每年有很多栅栏要修理.他总是骑着马穿过每一个栅栏并修复它破损的地方. 题目描述 John是一个与其他农民一样懒的人.他讨厌骑马,因此从来不两次经过一个栅栏.你必须编一个程序,读入栅栏网络的描述,并计算出一条修栅栏的路径,使每个栅栏都恰好被经过一次.John能从任何一个顶点(即两个栅栏的交点)开始骑马,在任意一个顶点结束. 每一个栅栏连接两个顶点,顶点用1到500标号(虽然有的农场并没有500个

比赛模板(持续更新中)

1.数据结构 (1)线段树单点更新 #include <cstdio> #include <cstdlib> #include <algorithm> #include <cstring> #include <cmath> #define MAXN (1<<19) using namespace std; int segTree[MAXN]; void update(int i, int lft, int rht, int index

东拼西凑的模板&#183;持续更新中

一.常用算法(应该不需要用到模板的那种常用) 1.1 快速幂 1 //https://blog.csdn.net/java_c_android/article/details/55802041 2 long long quickmod(long long a,long long b,long long m) 3 { 4 long long ans = 1; 5 while(b)//用一个循环从右到左便利b的所有二进制位 6 { 7 if(b&1)//判断此时b[i]的二进制位是否为1 8 { 9

ssh框架中spring整合hibernate的配置文件模板(带详细注释)

applicationContext.xml的配置文件模板 1 <?xml version="1.0" encoding="UTF-8"?> 2 <beans 3 xmlns="http://www.springframework.org/schema/beans" 4 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 5 xmlns:aop=&quo

Spring boot 通用配置文件模板

001 # ===================================================================002 # COMMON SPRING BOOT PROPERTIES003 #004 # This sample file is provided as a guideline. Do NOT copy it in its005 # entirety to your own application.               ^^^006 # ==

spring boot 配置文件动态更新原理 以Nacos为例

配置文件的动态更新 通常获取配置文件的方式 1, @Value 2. @ConfigurationProperties(Prefix) 如果是在运行时要动态更新的话, 第一种方式要在bean上加@RefreshScope 第二种方式是自动支持的. 以Nacos为为例,我们可以看下源码是如何实现的: Nacos获取配置中心是通过单独一个线程的长轮询获取的: com.alibaba.nacos.client.config.impl.ClientWorker.LongPollingRunnable 当

Spring Boot 持续更新中...

内容 Spring Boot入门 Spring Boot配置 Spring Boot与日志 Spring Boot与Web开发 Spring Boot与Docker Spring Boot与数据访问 Spring Boot启动配置原理 Spring Boot自定义starters Spring Boot与缓存 Spring Boot与消息 Spring Boot与检索 Spring Boot与任务 Spring Boot与安全 Spring Boot与分布式 Spring Boot与开发热部署