标签:data 文件配置 start rom nfa word coding depend ace
1 <dependency> 2 <groupId>mysql</groupId> 3 <artifactId>mysql-connector-java</artifactId> 4 </dependency> 5 <dependency> 6 <groupId>org.mybatis.spring.boot</groupId> 7 <artifactId>mybatis-spring-boot-starter</artifactId> 8 <version>1.1.1</version> 9 </dependency>
1 mybatis.type-aliases-package=com.neo.entity spring.datasource.driverClassName = com.mysql.jdbc.Driver spring.datasource.url = jdbc:mysql://localhost:3306/test1? 2 useUnicode=true&characterEncoding=utf-8 3 spring.datasource.username = root 4 spring.datasource.password = root
@SpringBootApplication @MapperScan("com.neo.mapper") public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } }
或者在Mapper雷尚添加注解@Mapper
1 public interface UserMapper { 2 @Select("SELECT * FROM users") @Results({ @Result(property = "userSex", column = "user_sex", javaType = UserSexEnum.class), @Result(property = "nickName", column = "nick_name") }) List<UserEntity> getAll(); 3 @Select("SELECT * FROM users WHERE id = #{id}") 4 @Results({ @Result(property = "userSex", column = "user_sex", javaType = UserSexEnum.class), 5 @Result(property = "nickName", column = "nick_name") }) 6 UserEntity getOne(Long id); @Insert("INSERT INTO users(userName,passWord,user_sex) VALUES(#{userName}, #{passWord}, #{userSex})") void insert(UserEntity user); 7 @Update("UPDATE users SET userName=#{userName},nick_name=#{nickName} WHERE id =#{id}") 8 void update(UserEntity user); 9 @Delete("DELETE FROM users WHERE id =#{id}") 10 void delete(Long id); }
标签:data 文件配置 start rom nfa word coding depend ace
原文地址:http://www.cnblogs.com/zhaxiang/p/7151460.html