티스토리 뷰

[자동 배포]

- Travis를 이용한 자동배포

- S3 bucket에 파일들을 업로드 하는 방법.

(Travis CI, S3를 이용한 자동 배포 : https://jojoldu.tistory.com/265?category=635883  )


language: java
jdk:
- openjdk8

services:
- mysql

branches:
only:
- master
cache:
directories:
- '$Home/.gradle'

before_install:
- mysql -e 'CREATE DATABASE IF NOT EXISTS drinkit;'
- mysql -u root -e "CREATE USER 'jiwon'@'localhost' IDENTIFIED BY 'jiwon';"
- mysql -u root -e "GRANT ALL ON drinkit.* TO 'jiwon'@'localhost';"

script:
- travis_wait 30 ./gradlew clean build

before_deploy:
- zip -r drinkit *
- mkdir -p deploy
- mv drinkit.zip deploy/drinkit.zip

deploy:
- provider: s3
access_key_id: $AWS_ACCESS_KEY
secret_access_key: $AWS_SECRET_KEY
bucket: drinkit-bucket
region: ap-northeast-2
skip_cleanup: true
acl: public_read
wait-until-deployed: true
local_dir: deploy # deploy 디렉토리의 내용들만 S3로 전송
on:
repo: DrinKit-team-project/DrinKit-Backend
branch: master

- provider: codedeploy
access_key_id: $AWS_ACCESS_KEY # Travis repo settings에 설정된 값
secret_access_key: $AWS_SECRET_KEY # Travis repo settings에 설정된 값
bucket: drinkit-bucket # S3 버킷
key: drinkit.zip # 빌드 파일을 압축해서 전달
bundle_type: zip
application: drinkit # 웹 콘솔에서 등록한 CodeDeploy 어플리케이션
deployment_group: drinkit-group # 웹 콘솔에서 등록한 CodeDeploy 배포 그룹
region: ap-northeast-2
wait-until-deployed: true
on:
repo: DrinKit-team-project/DrinKit-Backend
branch: master


[Spring 디버거 사용방법 : http://jinhokwon.tistory.com/14, http://wonwoo.ml/index.php/post/396]

- log.debug("");

private static final Logger log = LoggerFactory.getLogger(AdminController.class);


[Spring Boot RestFul API 어노테이션]

@RequestBody  : http://lee-mandu.tistory.com/242

@PostMapping("/menus")
public MenuDto createMenu(@RequestBody String menuTotalInfo) {

@JsonProperty : https://goo.gl/JZM9aR

@Column(name="ACCOUNT_USERNAME")
@JsonProperty("nickname")
private String username;


JPA 관련 어노테이션 : https://jdm.kr/blog/121, http://wonwoo.ml/index.php/post/1530

@JsonIgnore
@Column(name = "ACCOUNT_REVIEWS")
@OneToMany(mappedBy = "writer")
private List<Review> reviews = new ArrayList<>();

@ManyToMany(cascade = {
CascadeType.PERSIST,
CascadeType.MERGE
})
@JoinTable(name = "account_menu",
joinColumns = @JoinColumn(name = "account_id"),
inverseJoinColumns = @JoinColumn(name = "menu_id")
)


@MappedSuperclass

@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public abstract class BaseEntity {
@CreatedDate
private LocalDateTime createdDate;

@LastModifiedDate
private LocalDateTime modifiedDate;


@RequestHeader

@PathVariable, @RequestParam, ResponseEntity


Exception 생성하여 사용하는 방법


[Spring Security]

Authentication



@Swagger


@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.ant("/api/**"))
.build();
}
}



@EnableWebMvc : http://modestdeveloper.tumblr.com/post/31971657507/enablewebmvc

@Configuration
@EnableWebMvc
public class WebMvcConfig implements WebMvcConfigurer {

@Bean
public FilterRegistrationBean<CharacterEncodingFilter> registercharacterEncodingFilterBean() throws Exception {
FilterRegistrationBean<CharacterEncodingFilter> filterRegistrationBean = new FilterRegistrationBean<>(characterEncodingFilter());
filterRegistrationBean.setName("CharacterEncodingFilter");
filterRegistrationBean.addUrlPatterns("/api/**");
filterRegistrationBean.setOrder(1);
return filterRegistrationBean;
}

private CharacterEncodingFilter characterEncodingFilter() {
CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
characterEncodingFilter.setEncoding("UTF-8");
characterEncodingFilter.setForceEncoding(true);
return characterEncodingFilter;
}
}










댓글