parent
524f149647
commit
a8f8dfa25b
@ -0,0 +1,35 @@
|
|||||||
|
package com.wanman.springbootmybatis.entity;
|
||||||
|
|
||||||
|
public class Article {
|
||||||
|
private int id;
|
||||||
|
private String title;
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getContent() {
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContent(String content) {
|
||||||
|
this.content = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "id:" + id + " title:" + title + " content:" + content;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package com.wanman.springbootmybatis.mapper;
|
||||||
|
|
||||||
|
import com.wanman.springbootmybatis.entity.Article;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface ArticleMapper {
|
||||||
|
//根据ID查询
|
||||||
|
@Select("select * from t_article where id = #{id}")
|
||||||
|
public Article getArticleById(int id);
|
||||||
|
}
|
@ -1 +1,6 @@
|
|||||||
spring.application.name=SpringBootMybatis
|
spring.application.name=SpringBootMybatis
|
||||||
|
# ?????????
|
||||||
|
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
|
||||||
|
spring.datasource.url=jdbc:mysql://10.10.14.210:22066/HuangHai_db?useUnicode=true&characterEncoding=utf-8&useSSL=false
|
||||||
|
spring.datasource.username=root
|
||||||
|
spring.datasource.password=DsideaL147258369
|
@ -1,13 +1,22 @@
|
|||||||
package com.wanman.springbootmybatis;
|
package com.wanman.springbootmybatis;
|
||||||
|
|
||||||
|
import com.wanman.springbootmybatis.entity.Article;
|
||||||
|
import com.wanman.springbootmybatis.mapper.ArticleMapper;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
class SpringBootMybatisApplicationTests {
|
class SpringBootMybatisApplicationTests {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ArticleMapper articleMapper;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void contextLoads() {
|
void contextLoads() {
|
||||||
|
Article brean = articleMapper.getArticleById(1);
|
||||||
|
System.out.println(brean);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in new issue