묻고 답해요
164만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
미해결실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
테스트 exception 관련 질문 입니다.
안녕하십니까 선생님의 강의 정말 유익하게 잘 보고 있습니다. 다름이아니라 상품주문 test 를 하게되면 ==== 오류 org.springframework.dao.InvalidDataAccessApiUsageException: id to load is required for loading; nested exception is java.lang.IllegalArgumentException: id to load is required for loading 이런식으로 납니다.그래서 id가 자동으로 생성이 안되는내용이라서 @GenereatedValue 가 이미 Item 에 id 에 선언되어있고 혹시나 해서 setId로 id 값 지정후 해보니 그다음으로는 == 오류 전문 java.lang.NullPointerException at jpabook.jpashoop.service.OrderService.order(OrderService.java:41) at jpabook.jpashoop.service.OrderService$$FastClassBySpringCGLIB$$f6e85b24.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at jpabook.jpashoop.service.OrderService$$EnhancerBySpringCGLIB$$ac50f3a2.order(<generated>) at jpabook.jpashoop.service.OrderServiceTest.상품주문(OrderServiceTest.java:44) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:686) at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60) at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131) at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149) at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140) at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84) at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115) at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105) at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37) at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104) at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:212) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:208) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:137) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:71) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:135) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) at java.base/java.util.ArrayList.forEach(ArrayList.java:1540) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) at java.base/java.util.ArrayList.forEach(ArrayList.java:1540) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:248) at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$5(DefaultLauncher.java:211) at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:226) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:199) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:132) at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:71) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:220) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:53) 이런식으로 NullPointEception 이 일어납니다.혹시 이렇게 되면 item class가 문제인지 또는 service 와 repository 문제인지 혹시 알고싶습니다.
-
해결됨스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
라이브러리 인식 오류
이클립스 환경인데요, build과정에서 오류가나서 프로젝트를 지우고 다시 불러왔는데 아예 gradle 라이브러리 인식을 못합니다.. ㅠㅠ 구글링을 엄청했는데도 못고쳐서 진도를 못나가고 있어요 The import org.springframework cannot be resolved 오류이름은 이거에요
-
해결됨스프링 시큐리티
(해결완료) AjaxSecurityConfig 클래스에서 cofigure 이전 강의코드에서 살짝 바뀌었으니 참고들 하세요!
이전 강의 코드 현재 강의 코드
-
미해결실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
@Transactional 애노테이션 질문
@Transactional 애노테이션만 붙이면 jpa기본편에서 배웠던 대로 해당 메소드를 아래와 같이 감싸서 실행하게 되는건가요? tx.begin() try { --- 메소드 실행 --- tx.commit() } catch (Exception e) { tx.rollback() } finally { em.close() } emf.close()
-
미해결스프링 시큐리티
(해결완료) 코드 변경사항 있습니다. 참고들 하세요!
package io.security.basicsecurity.security.provider; import io.security.basicsecurity.security.common.FormWebAuthenticationDetails; import io.security.basicsecurity.security.service.AccountContext; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.authentication.AuthenticationProvider; import org.springframework.security.authentication.BadCredentialsException; import org.springframework.security.authentication.InsufficientAuthenticationException; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.Authentication; import org.springframework.security.core.AuthenticationException; import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.transaction.annotation.Transactional; @Slf4j public class FormAuthenticationProvider implements AuthenticationProvider { @Autowired private UserDetailsService userDetailsService; @Autowired private PasswordEncoder passwordEncoder; public FormAuthenticationProvider(PasswordEncoder passwordEncoder) { this.passwordEncoder = passwordEncoder; } @Override @Transactional public Authentication authenticate(Authentication authentication) throws AuthenticationException { String username = authentication.getName(); String password = (String) authentication.getCredentials(); AccountContext accountContext = (AccountContext) userDetailsService.loadUserByUsername(username); if(!passwordEncoder.matches(password, accountContext.getAccount().getPassword())) { throw new BadCredentialsException("Invalid Password"); // throw new BadCredentialsException("BadCredentialsException"); } String secretKey = ( (FormWebAuthenticationDetails) authentication.getDetails() ).getSecretKey(); // FormWebAuthenticationDetails formWebAuthenticationDetails = (FormWebAuthenticationDetails) authentication.getDetails(); // String secretKey = formWebAuthenticationDetails.getSecretKey(); if(secretKey == null || ! secretKey.equals("secret")) { // if(secretKey == null || !"secret".equals(secretKey)) { throw new IllegalArgumentException("invalid Secret"); // throw new InsufficientAuthenticationException("InsufficientAuthenticationException"); } return new UsernamePasswordAuthenticationToken(accountContext.getAccount(), null, accountContext.getAuthorities()); // UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(accountContext.getAccount(), null, accountContext.getAuthorities()); // return authenticationToken; } @Override public boolean supports(Class<?> authentication) { return authentication.equals(UsernamePasswordAuthenticationToken.class); // return UsernamePasswordAuthenticationToken.class.isAssignableFrom(authentication); } }
-
해결됨실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
안녕하십니까? 도메인 설계시 인터페이스, 추상클래스 에 대한 의견을 듣고 싶습니다.
안녕하십니까? 강의 영상 모두 결제해서 잘 보고 있습니다. 바로 본론부터 말씀 드리면, 회사에서 여러개의 프로젝트를 준비하고 있고 그중 자주 쓰이는 공통적인 기능을 ( 회원, 게시판 등 ) 만들어 놓고 프로젝트마다 재활용하여 시간을 단축하자는 의견이 나왔습니다. 그래서 JPA 에서 사용하는 entity 도 인터페이스와 추상클래스를 사용해서 설계를 해보라고 해서 진행중에 있습니다. 들어가기 앞서, 스프링 프로젝트의 코드를 살펴보면 인터페이스를 잘 사용해서 설계를 잘 했다고 생각하고 있습니다.그러나 데이터베이스와 직접적인 연관이 없는 코드라서 자유롭게 쓸수 있었던것 같은데요. JPA 를 쓰고 있는 입장에서 인터페이스와 추상클래스를 사용해서 다형성을 구현할려고 할때마다 한계에 자꾸 봉착하는 느낌이 듭니다. 결국 도메인 클래스는 CRUD 가 중요한데, 인터페이스로는 실제 구현된 클래스가 뭔지 알수 없어 사용하기가 난감합니다. Item 과 Book 과 같이 강하게 결합 하는것에 대해서는 어느정도 수긍이 갑니다만, 거의 대부분은 그렇게 강하게 연결되는 경우가 잘 없는거 같아서요. 인터페이스를 쓰는경우도 잘 못본거 같습니다. 실무에서는 인터페이스와 추상클래스를 어느 정도 까지 사용하는지궁금합니다.
-
미해결스프링 시큐리티
(해결완료) successHandler 작동 안되시는분들 꼭 참고하세요
.defaultSuccessUrl("/") 이거를 꼭 successHandler위에 위치하세요.. 원래는 아래 있었습니다.. 1시간 삽질했네요..
-
해결됨스프링 시큐리티
(해결완료) FormAuthenticationProvider 클래스가 이전에 작성했던 CustomAuthenticationProvider 클래스였네요;
1. 클래스명 CustomAuthenticationProvider -> FormAuthenticationProvider 변경되었습니다. 2. class 위에 @Slf4j 애노테이션이 추가되었습니다.3. public FormAuthenticationProvider 생성자가 추가되었습니다. 4. authenticate 메서드 위에 @Transactional이 추가되었습니다. 다른분들은 저처럼 혼란스러워서 저번 강의 다시 보시지 않기를.. ---------------------------------------------------------- 5. SecurityConfig 클래스에 authenticationProvider 메서드에 passwordEncoder() 매개변수가 추가되었습니다.
-
미해결스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
JdbcMemberRepository에서 import 문제
선생님 안녕하세요. 우선 정말 이 수업을 개설해 주셔서 정말정말 감사하다는 말씀 드립니다. 프로젝트 수업으로 스프링 프레임워크에서 스트레스를 엄청 받다가 선생님의 강의를 듣고 한줄기 희망이 생겼습니다!!! 지금 DB 파트 강의에서 순수 JDBC 듣는 중인데, 원래는 오라클 SQL을 사용하려다 import 하는 부분에서 막히길래, 역시 강의와 다른 걸 쓰려니 힘들구나 싶어서ㅜㅜ 우선은 그냥 수업에서 사용하시는 H2로 다시 시도하고 원리를 좀 깨친 다음에 오라클로 재시도 하려 했습니다만.... 결국은 똑같은 곳에서 문제가 생기길래 이렇게 질문을 드립니다. H2에서 DB 생성하고, build.gradle에서 의존성 주입했고, application.properties에 url, driver-class-name까지 설정은 완료한 상태입니다. 그러고나서 JdbcMemberRepository 코드를 작성했는데, 이상하게 이 부분만 import에서 오류가 생깁니다. import org.springframework.jdbc.datasource.DataSourceUtils;(밑줄 친 부분에 오류가 있다고 빨간 줄이 생김) 에러메시지는 "The import org.springframework.jdbc cannot be resolved" 라고 뜨고, 클래스를 새로 생성하라는 식으로만 나오고 있습니다 ㅜㅜ 강제로 실행시키면 다음 메시지가 나옵니다. "Description:Parameter 0 of constructor in hello.hellospring.SpringConfig required a bean of type 'javax.sql.DataSource' that could not be found. The following candidates were found but could not be injected: - Bean method 'dataSource' in 'JndiDataSourceAutoConfiguration' not loaded because @ConditionalOnClass did not find required class 'org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType' - Bean method 'dataSource' in 'XADataSourceAutoConfiguration' not loaded because @ConditionalOnClass did not find required class 'javax.transaction.TransactionManager' Action: Consider revisiting the entries above or defining a bean of type 'javax.sql.DataSource' in your configuration. " 사용 환경은 윈도10 / Eclipse EE / Spring boot 2.3.3. 입니다.수업을 착실히 들었다고 생각했는데 혹시 설정 같은 걸 빼먹은 게 아닌지 싶은데, 구글링해도 답을 얻을 수 없어 여쭤봅니다. 감사합니다 !!
-
미해결실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
update에대한 질문입니다!
지금은 Book 상품등록, 상품수정의 기능만 한다고 하셨는데 영화와 음반까지 추가하려면 단순히 controller와 service에 메서드들을 추가해서 로직을 짜면 되는건가요? 아니면 메서드를 추가안하고 다른 방법이 있을까요?
-
미해결스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
sequence 변수에 대하여 너무 궁금한 점이있습니다.
안녕하세요. 김영한 강사님. 이번 강의를 듣던 도중 실무 이야기를 몇번 하셨는데요. sequence 변수에 대해 궁금하 점이 생겼습니다. Member를 save할때마다 id 값을 1씩 증가시켜주는데요. 이건 DB기반이 아니라 메모리 기반이기 때문에 id값을 이렇게 임의로 정해주는 것인가요? 실무에서 DB는 id 값을 auto increment를 주지 않고 이런 식으로 sequence를 올려가며 회원 저장마다 id값을 지정해주는 건가요? 제가 이해한것이 맞다면 서버가 재가동 될때마다 모든 회원 DB를 다 읽어와야 하는 시스템인것 같은데 제가 이해한바가 맞는지요.. 너무 궁금해서 그냥 넘어갈수가 없었습니다. 감사합니다.
-
미해결실전! 스프링 부트와 JPA 활용2 - API 개발과 성능 최적화
조회 v3.1에서 to One 관계는 모두 페치 조인하고 나머지 컬렉션은 지연로딩을 유지했을때 다음과 같은 에러가 발생합니다.
좋은 강의 감사합니다. 조회 v3.1에서 to One 관계는 모두 페치 조인하고 나머지 컬렉션은 지연로딩을 유지했을때 다음과 같은 에러가 발생합니다. query specified join fetching, but the owner of the fetched association was not present in the select list 고심하던 중 @Query부분을 value 와 countQuery로 나눠어서 처리 한 결과 정상적으로 조회 됬습니다.(Spring Data Jpa사용) 예) @Query(value = "select u from User u join fetch u.store s", countQuery = "select count(u) from User u") Page<User> findAllUser(Pageable pageable); 꼭 countQuery를 사용해야 하는지 궁금합니다.
-
미해결스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
옛날 사람 아닙니다!! ㅠㅠ
공공기관 취직해서 1년 근무했는데 옛날사람들이 쓰는 기술이라고 하는 기술들만 쓰고 있습니다. ㅠㅠ 잘 공부해서 최신사람으로 거듭나겠습니다! 응원해주세요... 따로 메시지 보내고 싶었는데 찾을수가 없어서 여기 남깁니다.
-
미해결실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
thymeleaf 의 경로를 못찾는다고 나오네요
indx.html을 /src/main/resourcee/static/index.html을 넣어도 못찾네요 hello예제에서는 "template might not exist or might not be accessible by any of the configured Template Resolvers" 로 나오네요 경로가 차이가 있는건지 모르겠습니다. 아래는 grandle 설정입니다 어떤 문제가 있는건지 모르겠습니다. plugins { id 'org.springframework.boot' version '2.1.16.RELEASE' id 'io.spring.dependency-management' version '1.0.9.RELEASE' id 'java'}group = 'jpabook'version = '0.0.1-SNAPSHOT'sourceCompatibility = '1.8'configurations { compileOnly { extendsFrom annotationProcessor }}repositories { mavenCentral()}dependencies { implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' implementation 'org.springframework.boot:spring-boot-starter-web' compileOnly 'org.projectlombok:lombok' runtimeOnly 'com.h2database:h2' annotationProcessor 'org.projectlombok:lombok' testImplementation 'org.springframework.boot:spring-boot-starter-test'}
-
미해결실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
post vs put
안녕하세요. 보통 리소스를 수정하는데 put 메서드를 사용한다고 알고 있는데, post를 사용한 이유 같은게 있나요?
-
미해결실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
Category 계층 구조를 보고 질문드립니다.
안녕하세요. 영한님 강의 잘 듣고 있습니다. 감사합니다. Category Entity에서 parent와 child 만드는 것을 보고 게시판에서 댓글과 대댓글 관계를 생각해보았는데 댓글 Entity에서 대댓글을 List로 담고 똑같은 계층구조로 구현하는게 객체지향적인 설계가 맞을까요?
-
미해결실전! 스프링 부트와 JPA 활용2 - API 개발과 성능 최적화
안녕하세요. Unique Index 데이터 저장에 대해서 질문드립니다.
안녕하세요. 강의 잘 듣고 많은걸 배우고 있습니다. 현재 강의와는 안 맞을 수 있는내용이지만.. 많은 고민이 되어 질문드립니다ㅜ 예를들어 Team이라는 테이블이 있고, name이라는 Column이 Unique Index로 설정되어 있는 상태입니다. CrudRepository의 save 함수를 이용해 저장하고 있고 Custom Exception을 핸들링해서 "이미 저장되어 있습니다."라는 응답값을 반환하는것이 목표입니다. 현재 고민하고 있는 방법은 1. Insert 쿼리를 사용하기전에 이미 저장된 name이 있는지 Select 쿼리로 조회해 있다면 Custom Exception을 발생. -> 팀을 생성할때마다 Select 쿼리를 발생 2.try ... catch로 DataIntegrityViolationException을 잡아 Custom Exception 발생 -> DataIntegrityViolationException이 넓은 범위의 제약조건을 포함하고 있는 것으로 알고있어서 DuplicateKey ErrorCode로 잡아서 Custom Exception을 발생시켜야하나 싶습니다.. 혹시 실무에서는 위의 방법 중 하나 혹은 다른 방법을 사용해 어떤식으로 해결하는지 궁금합니다
-
미해결스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
안녕하세요 5강 관련하여 질문이 있습니다
안녕하세요 강사님. 5강 내용 대로 직접 코드를 작성하다 기본적인 부분에 문제가 생겨 질문 드립니다. 브라우저에 localhost:포트번호/hello 를 요청하면 404에러가 뜹니다....! Controller에서 @GetMapping("hello") 요청, addAttribude , return 값 에 오타가 없는지 확실히 살펴보았고 console에선 Application이 정상적으로 스타트 되었다는 출력만 나올 뿐 별 다른 에러가 나타나지도 않습니다. 제가 어느 부분을 더 살펴야 하는지 조언 부탁드리겠습니다. 코드나 추가 자료가 필요하시다면 답변 달아주시면 추가하여 수정하겠습니다. 감사합니다.
-
미해결실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
셀프로 양방향 연관관계 관련 질문입니다.
안녕하세요, 먼저 강의를 잘 듣고 있는 학생 1인 입니다. ㅎㅎ 엔티티 클래스 개발2 강의 중 셀프로 양방향 연관관계 관련 질문입니다. Category 엔티티에서 // 자식입장에서 바라보는 부모 @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "parent_id") private Category parent; 위의 JoinColumn시 "category_id"가 아니라, "parent_id"로 작성해야 되는 이유를 알 수 있을까요? 셀프를 제외한 일반적인 양방향 연관관계에서 "연관관계 주인" 쪽에서 연관관계 거울 쪽을 Join할 때 연관관계 거울의 KEY를 명시해 주는데, 이와 마찬가지로 parent_id가 아닌 category_id가 아닌지... 궁금합니다. 실제로 바꿔서 했을 때, 오류가 발생했습니다...
-
해결됨스프링 시큐리티
SecurityContextHolder , SecurityContext 질문 드립니다.
안녕하세요.. 좋은 내용의 강의를 잘 듣고 있습니다. 현재 1. 스프링 시큐리티 주요 아키텍처 이해 4) 인증저장소( SecurityContextHolder , SecurityContext) 관련해서 2가지 질문이 있는데요. [질문1] 예제 설명에서 Main Thread 에서 자식 Tread 를 새로 생성해서, 테스트 하는 예제가 있는데요. 실제 업무에서, MVC 모델에서 자식 Thread 를 선언해서, 사용하는 예제를 그동안 못 봐서요. @Controller 에서 @Service 를 호출하고, 대부분 처리하는 방식인데요. 자식 쓰레드를 만드는 패턴은 실제적으로 어느때 사용하나요? [질문2] 기본 설정이 strategyName = MODE_THREADLOCAL 인데요. 자식 쓰레드가 Authentication authentication = SecurityContextHolder.getContext().getAuthentication() 로 접근할때는 안 되지만, 세션으로 get 으로, 호출하면, 같은 WAS 세션에 존재함으로, authentication 정보를 가져올 수 있는 건 아닌지요? 개인적으로 2가지 문의사항이 있어서, 질문드립니다. 감사합니다.