티스토리 뷰
Spring Boot DynamoDb연동하기
ServerModule.java
import com.amazonaws.auth.AWSCredentialsProvider;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
public abstract class ServerModule {
@Value("$")
String awsRegion;
public abstract AWSCredentialsProvider getCredentialsProvider();
@Bean
public AmazonDynamoDB dynamoDB(AWSCredentialsProvider credentialsProvider) {
return AmazonDynamoDBClientBuilder
.standard()
.withCredentials(credentialsProvider)
.withRegion(this.awsRegion)
.build();
}
}
LocalServerModule.java
import com.amazonaws.auth.AWSCredentialsProvider;
import com.amazonaws.auth.DefaultAWSCredentialsProviderChain;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.*;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
@Profile({"local"})
@Slf4j
@Configuration
@EnableAsync
@EnableScheduling
public class LocalServerModule extends ServerModule {
@Bean
@Override
public AWSCredentialsProvider getCredentialsProvider() {
log.warn("[DefaultAWSCredentialsProviderChain]");
return DefaultAWSCredentialsProviderChain.getInstance();
}
}
application-local.yml
1
2
|
aws:
region: us-west-2
|
cs |
AwsDynamoDbTest.java
@ActiveProfiles("local")
@RunWith(SpringRunner.class)
@SpringBootTest
@Slf4j
public class AwsDynamoDbTest {
@Autowired
AmazonDynamoDB amazonDynamoDB;
@Autowired
AWSCredentialsProvider awsCredentialsProvider;
private Worker worker;
@Test
public void name() {
String tableName = "<table_name>";
DescribeTableResult describeTableResult = amazonDynamoDB.describeTable(tableName);
System.out.println(describeTableResult);
String streamArn = describeTableResult.getTable().getLatestStreamArn();
log.info("streamArn:{}",streamArn);
}
}
end.
728x90
'Language > JAVA' 카테고리의 다른 글
LMAX Disruptor 튜터리얼 (0) | 2018.05.10 |
---|---|
java uuid만들기 (0) | 2018.05.09 |
java do while (0) | 2018.05.02 |
java 재귀 호출, 재귀 함수 (0) | 2018.04.05 |
RxJava에 대해 알아보자 - 제3편 데이터 형변환 해서 Flowable로 만들기(flatmap) (0) | 2018.04.04 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- docker container tissue box
- 싱가폴
- vim
- 도커티슈박스
- 도커각티슈박스
- docker container case
- docker container whale
- 이직
- docker container tissue
- 도커컨테이너
- 도커티슈케이스
- 2017 티스토리 결산
- docker container
- 개발자
- shellscript
- Linux
- 도커각티슈케이스
- Sh
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
글 보관함