본문 바로가기

Java7

Jsoup으로 크롤링하기 build.gradle에 의존성 추가 implementation 'org.jsoup:jsoup:1.13.1' url로 크롤링할 페이지 접근하기 String crawlingURL = "크롤링할 주소"; Document document = Jsoup.connect(crawlingURL).get(); 원하는 정보 찾기 getElementById getElementsByTag getElementsByClass getElementsByAttribute 특정 정보 text로 변환하기 String info = elements[0].select("td").text(); 공식 문서에 더욱 자세한 정보가 나와있습니다. https://jsoup.org jsoup Java HTML Parser, with the best of.. 2020. 4. 12.
생성시간, 수정시간 자동화(JPA Auditing)  1. BaseTimeEntity 클래스 생성 kotlin 코드 @MappedSuperclass @EntityListeners(AuditingEntityListener::class) abstract class BaseTimeEntity(@CreatedDate var createdDate: LocalDateTime? = null, @LastModifiedDate var modifiedDate: LocalDateTime? = null) java 코드 @Getter @MappedSuperclass @EntityListeners(AuditingEntityListener.class) public abstract class BaseTimeEntity { @CreatedDate private LocalDateTim.. 2019. 10. 22.
Jackson 라이브러리 Jackson 라이브러리 객체를 JSON 형식으로 변환해준다. 프로퍼티 즉, Getter, Setter를 기준으로 작동한다. Java의 프로퍼티는 보통 Getter와 Setter의 이름 명명 규칙으로 정해진다. Jackson의 매핑을 프로퍼티가 아닌 멤버변수로 하고 싶다면 @JsonProperty를 사용한다. public class Person { @JsonProperty("name") private String myName = "Mommoo"; } // {"name": "Mommoo"} @JsonAutoDetect로 매핑 법칙을 바꿀 수 있다. // 멤버 변수 뿐만 아니라, 기본 정책인 Getter 역시 데이터 매핑이 진행된다. @JsonAutoDetect(fiedlVisibility = JsonAut.. 2019. 10. 22.