Spring 4

Spring Boot 스케줄러 @Scheduled 어노테이션 사용

※ 1분마다 실행하여 특정폴더의 1분전 화일 삭제하기 @SpringBootApplication에 @EnableScheduling 선언 @EnableScheduling @SpringBootApplication public class DevApplication { @Bean public ObjectMapper objectMapper() { ObjectMapper objectMapper = new ObjectMapper(); SimpleModule module = new SimpleModule(); objectMapper.registerModule(module); return objectMapper; } public static void main(String[] args) { SpringApplication...

Spring 2023.10.27

Spring Boot에서 타임리프 이미지 동적 리소스 사용하기

WebMvcConfiguration 컨트롤러에서 요청하여 웹 리소스로 한 번 더 매핑 작업 import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.CacheControl; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.spring..

Spring 2023.10.11

Spring Boot + WebSocket + UDP 데이터 통신

C#으로 제작된 dummy 프로그램 WebSocket 클래스 1. @ServerEndpoint 설정 2. onMessage - UDP 데이터 송신 3. onClose - DatagramSocket close(); 4. data - UDP 데이터 조합 package com.coforward.dev.controller; import org.json.simple.JSONObject; import org.springframework.stereotype.Service; import org.springframework.web.socket.WebSocketSession; import javax.websocket.*; import javax.websocket.server.ServerEndpoint; import jav..

Spring 2023.07.18

Spring Boot + build.gradle + WebSocket 연동

build.gradle 에서 dependencies websocket 추가- implementation 'org.springframework.boot:spring-boot-starter-websocket' build.gradle 원본 소스(버젼마다 호환성의 문제로 전체 source) plugins { id 'org.springframework.boot' version '2.6.1' id 'io.spring.dependency-management' version '1.0.11.RELEASE' id 'java' } group = 'com.coforward' version = '0.0.1-SNAPSHOT' sourceCompatibility = '1.8' configurations { compileOnly {..

Spring 2023.07.17