因为常用,所以懒
文件模板的存在就是因为常用,但自己又懒,又想高效。这里分享一下IDEA 的文件模板。
打开文件模板的方式
自定义*.yml 文件模板
spring boot 常用的 application.yml 配置
spring:
# profiles:
# active: dev
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3307/usertest?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT
username: root
password: 123456
server:
port: 8080
mybatis:
config-location: classpath:mybatis-config.xml
自定义 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>
<mappers>
<!--<mapper resource="mapper/UserMapper.xml"/>-->
</mappers>
</configuration>
自定义 XxxxMapper.xml
mybatis-spring-boot 常用的Mapper 配置
<?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.example.ssmdemo.entity.User">
<select id="listUser" resultType="com.example.ssmdemo.entity.User">
select * from my_user
</select>
<select id="getUserById" resultType="com.example.ssmdemo.entity.User">
select * from my_user where id = #{id}
</select>
<insert id="addOne" parameterType="com.example.ssmdemo.entity.User">
insert into my_user (id,name,age,email,version) VALUES (#{id},#{name},#{age},#{email},#{version})
</insert>
</mapper>