본문 바로가기
728x90
반응형

spring64

[Maven Build Error] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project : Fatal error compiling 메이븐 빌드 시 Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project : Fatal error compiling 와 같은 오류가 발생했다면 jdk 버전을 확인해보면됩니다. 2021. 11. 17.
[Spring] dynamic Scheduler 다이나믹 스케줄링 @ImportResource({ "classpath:scheduler/context-scheduler.xml" }) 나 @Scheduled 어노테이션을 사용하지 않고 스케줄을 동적으로 등록하는 두가지 방법을 알아보겠습니다. 1. ThreadPoolTaskScheduler 꼭 아래 예시와 같이 사용할 필욘 없지만, Map에 scheduler를 저장해놓고 destroy 할 수 있습니다. @Service public class SchedulerServiceImpl implements SchedulerService { private final Map schedulerMap = new ConcurrentHashMap(); public SchedulerServiceImpl() { Set typeList = ...;.. 2021. 11. 9.
[Spring Batch] step 중지/통과 하기 Step 실행 중일 때 다음 단계로 넘어가지 않고 중지하는 방법은 throw 하면 됩니다. public class PoisonPillItemProcessor implements ItemProcessor { @Override public T process(T item) throws Exception { if (isPoisonPill(item)) { throw new PoisonPillException("Poison pill detected: " + item); } return item; } } 이번 단계는 지나치고 다음 단계로 넘어가는 방법은 null을 리턴하면됩니다. public class PoisonPillItemProcessor implements ItemProcessor { @Override pub.. 2021. 10. 21.
[Spring] cannot deserialize from Object value (no delegate- or property-based Creator) 아래와 같은 로직 실행에서 cannot deserialize from Object value (no delegate- or property-based Creator) 가 발생하였습니다. @Getter @AllArgsConstructor public class UserDTO { private String name; private int age; } @RestController public class UserController { @PostMapping(value = "/user", consumes = MediaType.APPLICATION_JSON_VALUE) public String user(@RequestBody UserDTO param) { return param.getName(); } } jacks.. 2021. 8. 18.
[Spring Security5] 권한 계층구조(roleHierarchy) 설정 1. roleHierarchy 설정인가 관련해서는 AccessDecisionManager를 사용합니다. SecurityContextHolder에 저장되어있는 Authentication이 접근하는 리소스에 적절한 ROLE을 가지고 있는지 확인합니다. 확인하는 방법은 세 가지(AffirmativeBased, ConsensusBased, UnanimousBased)가 있는데 그중 AffrimativeBased(여러 Voter 중 하나라도 허용하면 허용)를 기본전략으로 사용합니다.<pre id="code_1628819619550" class="java" data-ke-language="java" dat.. 2021. 8. 13.
[SpringBoot] Test환경에 H2 적용하기 다음과 같이 db구성이 되어있을때 Test환경에 H2 적용하는 방법입니다. https://moonsiri.tistory.com/53 [Spring] java config로 hikari datasource, transaction aop 설정 pom.xml org.springframework.boot spring-boot-starter-jdbc org.mybatis.spring.boot mybatis-spring-boot-starter 2.1.3 org.apache.commons commons-dbcp2 mysql mysql-connector-java runtime application.ym.. moonsiri.tistory.com 우선 pom.xml에 dependency를 추가합니다. com.h2datab.. 2021. 8. 4.
[Spring Security] redis 세션에서 SecurityContext 수정 FindByIndexNameSessionRepository의 save 메소드를 사용하여 SecurityContext 수정할 수 있습니다. @Resource(name = "sessionRepository") private FindByIndexNameSessionRepository findByIndexNameSessionRepository; public void refreshSecurityContext(String targetUsername) { // targetUsername의 session 모두 조회 Map sessionMap = findByIndexNameSessionRepository.findByIndexNameAndIndexValue(FindByIndexNameSessionRepository.PRI.. 2021. 7. 12.
[SpringBoot] JPA Projection Projection은 Entity의 속성이 많을 때 일부 데이터만 조회하는 방법입니다. 아래 UserEntity를 참고하여 설명하겠습니다. @Entity @Table(name = "user") @NoArgsConstructor(access = AccessLevel.PROTECTED) public class UserEntity { @Id @Column(name = "user_id", nullable = false) @GeneratedValue(strategy = GenerationType.IDENTITY) private Long userId; @Column(length = 50, nullable = false) private String name; @Column(length = 50, nullable = .. 2021. 6. 23.
[Spring] JPA 연관 관계 매핑 및 제거 user와 dept 테이블을 맵핑하는 user_dept 테이블이 존재할 때, Entity의 객체 연관관계를 맵핑하여 영속 상태의 entity를 만들어 보겠습니다. @Entity @Table(name = "user") @NoArgsConstructor(access = AccessLevel.PROTECTED) public class UserEntity { @Id @Column(name = "user_id", nullable = false) @GeneratedValue(strategy = GenerationType.IDENTITY) private Long userId; @Column(length = 50, nullable = false) private String name; @Column(length = 50.. 2021. 6. 18.
[SpringBoot2] Mybatis + JPA + QueryDsl 설정 https://moonsiri.tistory.com/53 기존에 설정해둔 DB Configuration에 설정을 추가하겠습니다  1. JPA 설정 pom.xml org.springframework.boot spring-boot-starter-data-jpa  DatabaseConfig.java@Configuration@EnableJpaRepositories( basePackages = "com.moonsiri.**.repository", entityManagerFactoryRef = "entityManagerFactory", transactionManagerRef = "jpaTxManager")@MapperScan( basePackages = "com.moonsiri.*.. 2021. 6. 10.
728x90
반응형