Skip to content

dunhanson/tablestore-spring-boot-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tablestore-spring-boot-starter

开始

依赖

<dependency>
    <groupId>site.dunhanson</groupId>
    <artifactId>tablestore-spring-boot-starter</artifactId>
    <version>0.0.1</version>
</dependency>

application.yml

aliyun:
  tablestore:
    end-point: 'XXXXXX'
    access-key-id: 'XXXXXX'
    access-key-secret: 'XXXXXX'
    instance-name: 'XXXXXX'

java

实体类

@Data
@Table(tableName = "archives", indexName = "archives_index")
public class Archives {
    private String id;
    private String title;
    private String content;
    private String createTime;
    private String updateTime;
}

查询

@RunWith(SpringRunner.class)
@SpringBootTest
public class StartTest {
    @Resource
    private TablestoreTemplate tablestoreTemplate;

    @Test
    public void start() {
        // query
        TermQuery query = new TermQuery();
        query.setFieldName("id");
        query.setTerm(ColumnValue.fromString("d201c4b1-6db6-4e06-b5db-cbb796b2e56b"));
        // search
        PageInfo<Archives> pageInfo = tablestoreTemplate.search(Archives.class, query);
        pageInfo.getRecords().forEach(System.out::println);
    }
}

参考

表格存储 Tablestore

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages