java项目开发常用配置文件模板

发布时间 2023-09-25 16:28:51作者: ymworkroom

mybatis config文件

 1 <?xml version="1.0" encoding="UTF-8" ?>
 2 <!DOCTYPE configuration
 3         PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
 4         "http://mybatis.org/dtd/mybatis-3-config.dtd">
 5 <configuration>
 6     <properties resource="jdbc.properties" />
 7     <typeAliases>
 8         <package name="" />
 9     </typeAliases>
10     <environments default="development">
11         <environment id="development">
12             <transactionManager type="JDBC"/>
13             <dataSource type="POOLED">
14                 <property name="driver" value="${jdbc.driver}"/>
15                 <property name="url" value="${jdbc.url}"/>
16                 <property name="username" value="${jdbc.username}"/>
17                 <property name="password" value="${jdbc.password}"/>
18             </dataSource>
19         </environment>
20     </environments>
21     <mappers>
22         <package name=""/>
23     </mappers>
24 </configuration>

mybatis mapper

1 <?xml version="1.0" encoding="UTF-8" ?>
2 <!DOCTYPE mapper
3         PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
4         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
5 <mapper namespace="">
6     
7 </mapper>

spring自动注入

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <beans xmlns="http://www.springframework.org/schema/beans"
 3        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 4        xmlns:context="http://www.springframework.org/schema/context"
 5        xsi:schemaLocation="http://www.springframework.org/schema/beans
 6        https://www.springframework.org/schema/beans/spring-beans.xsd
 7        http://www.springframework.org/schema/context
 8        http://www.springframework.org/schema/context/spring-context.xsd">
 9 
10     <!--准备SpringIOC自动注入-->
11     <!--
12         1.准备环境
13             xmlns:context="http://www.springframework.org/schema/context"
14 
15             http://www.springframework.org/schema/context
16             http://www.springframework.org/schema/context/spring-context.xsd
17 
18         2.开启自动注入
19             <context:annotation-config/>
20 
21     -->
22     <!--开启⾃动化装配(注⼊)-->
23     <context:annotation-config/>
24     <bean id="userDao" class="com.xxx.dao.UserDao"/>
25     <bean id="userService" class="com.xxx.services.UserSevice"/>
26 </beans>

mysql-propertise

jdbc.driver=com.mysql.cj.jdbc.Driver
jdbc.url=jdbc:mysql://127.0.0.1:3306/dbname?serverTimezone=UTC&useSSL=false&characterEncoding=utf-8
jdbc.username=root
jdbc.password=root