package com.takensoft.pohangTp; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; import org.springframework.web.servlet.view.BeanNameViewResolver; import org.springframework.web.servlet.view.json.MappingJackson2JsonView; import java.text.SimpleDateFormat; import java.util.TimeZone; @SpringBootApplication class PohangTpApplication { public static void main(String[] args) { SpringApplication.run(PohangTpApplication.class, args); } /** * JSON Parser 라이브러리 Class Bean 설정 * * @author 서영석 * @since 2023.10.24 */ @Bean(name = "objectMapper") public ObjectMapper getObjectMapper() { ObjectMapper mapper = new ObjectMapper(); //기본 날짜 포맷 비활성화 mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); //새로운 날짜 포맷 세팅 SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); mapper.setDateFormat(dateFormat); mapper.setTimeZone(TimeZone.getTimeZone("Asia/Seoul")); return mapper; } @Bean(name="jsonView") public MappingJackson2JsonView getJsonView () { ObjectMapper objectMapper = getObjectMapper(); MappingJackson2JsonView jsonView = new MappingJackson2JsonView(objectMapper); jsonView.setExtractValueFromSingleKeyModel(true); return jsonView; } }