묻고 답해요
141만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
해결됨[개념은 호옹~, 실습 빡] 스프링 부트, 입문!
22강 질문입니다.
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요.CommentRepositoryTest에서 findByNickname를 실행할때 아래와 같은 오류가 나타납니다. org.springframework.dao.InvalidDataAccessApiUsageException: Could not locate ordinal parameter [1], expecting one of []; nested exception is java.lang.IllegalArgumentException: Could not locate ordinal parameter [1], expecting one of []가 나타나는데, 찾아보니 @Param을 하라고 하네요. 근데 @Param은 @Query를 사용할때에 대한 해결방안인데, xml로 쿼리를 작성한 findByNickname에서는 어떻게 해결해야하나요?
-
해결됨실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
웹 계층 파트에서 백엔드 개발자가 하는 역할이 궁금합니다.
[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예)[질문 내용]안녕하세요. 김영한님의 스프링, 스프링부트 강의를 정말 재밌게 듣고 있는 한 대학생입니다. 강의를 듣던 중에 공부방향에 대해서 궁금한 것이 생겼는데요.이번 웹 계층 개발 파트에서는 특히 js나 css에 대한 내용들이 thymleaf와 함께 많이 다루어지는 것 같습니다.물론 기본적인 html태그들은 그냥 자주 보다보면 외워지겠지만 이런 부분들을 본격적으로 따로 공부할 필요가 있는지 궁금합니다. 나중에 실무에서 제가 DB설계를 하고 도메인, 서비스 계층을 짜는 것은 상상이 되고 지금 공부하고 있는 방향과도 맞는 것 같아서 재밌을 것 같은데,이런 프론트적인 부분? 은 그냥 복붙하고 넘기면 되는지, 아니면 실무에서 제가 실제로 다루게 될 부분일지 경계가 모호한 것 같습니다.정리하자면, 1. 실무에서 백엔드 개발자는 어떤 일을 주로 맡게 되는지, 2. 그래서 이번 웹 계층 파트에서 다루어지는 thymleaf나 js,css, html 내용을 본격적으로 공부해야 하는지 궁금합니다.
-
미해결스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
회원 서비스 개발 단축키 에러 / .ifPresent부분이 에러
[질문 내용]회원서비스개발에서 2:18에1. 무슨 단축키를 누르면 Optional<Member> byName = 이 뜨나요? 저는 그냥 타이핑했는데 어떻게 하면 그렇게 생기죠?2.그리고 단축키 command option v 로 byName을 result로 변경했는데 그것도 단축키를 하면 왜 단축키를 했을 때 수업처럼 옵션이 안뜰까요 3.Optional<Member> byName = 부분 지우고result부분 지우고 코드 정리했을 때 저는.ifPresent부분이 에러가 납니다.4.강의에 4:56 부분 control + t 로 method입력해서 Extract Method 가 뜨는데 저는 안뜹니다.command option m 단축키로 Extract Method를 시도했는데 사용할수없다는데..어떻게해야되나요확인부탁드릴게요...
-
해결됨스프링 시큐리티
Ajax로그인 - loginProcessingUrl("/api/login") 관련 질문있습니다
안녕하세요 강사님. 강의를 따라 실습하는데 강사님과 다르게 동작합니다. 이유를 못찾아서 도움이 필요합니다 ㅠㅠ7) Ajax로그인 구현 & CSRF설정 15:00 부분강의에서는 브라우저에서 window.location = '/api/login?error=true&exception=' + xhr.responseJSON.message;호출이후 서버에서 로그인 컨트롤러가 호출되는데,저는 window.location 이후 AjaxLoginAuthenticationEntryPoint 가 다시 호출됩니다.그래서 AjaxSecurityConfig 클래스에 .antMatchers("/api/login/**").permitAll() 를 추가해서 테스트 해보았더니 컨트롤러가 호출 되었습니다.왜 강사님과 다르게 저는 window.location 이후 AjaxLoginAuthenticationEntryPoint가 왜 다시 호출되는지 알 수 있을까요?https://github.com/GwanUk/basicsecurity.git
-
해결됨스프링 시큐리티
매니저 권한으로 로그인하지 않아도 매니저 권한자원에 접근이 가능한데 이유를 모르겠습니다 ㅠㅠ
매니저 권한으로 로그인하지 않아도 매니저 권한자원에 접근이 가능한데 이유를 모르겠습니다 ㅠㅠhttps://github.com/whitewise95/springSecurity 입니다 ㅠㅠ
-
미해결실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
로깅 하이버네이트 SQL
main] org.hibernate.SQL : drop table if exists category CASCADE 이런 식으로 전부 다 main] org.hibernate.SQL 오류로 인해서 table 형태가 보이지 않아요..yml에 들어가보니 logging.level.org.hibernate.SQL: debug에 빨간불이 들어옵니다. 어떻게 하면 해결할 수 있을까요?
-
해결됨실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
13:41 쯤에 데이터를 다시 넣어줘야 한다는 부분이 이해가 잘 안갑니다.
13:41 부분에서 데이터를 끄집어 내서 파라미터 넣고 다 시 넣어줘야한다. 고 설명해주시는데요왜 이렇게 해야 하는건지 이해가 잘 안됩니다. 안해주면 어떤 문제가 발생하는지 궁금합니다.
-
미해결실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
이제 쿼리 파라미터 외부 라이브러리 spring 3.0 지원합니다.
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요.1. 강의 내용과 관련된 질문을 남겨주세요.2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요.(자주 하는 질문 링크: https://bit.ly/3fX6ygx)3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요.(질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG)질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요.=========================================[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예)[질문 내용]수업자료 pdf 16~17 page에 나와있는 https://github.com/gavlyukovskiy/spring-boot-source-decorator 에서 이제 spring boot 3.0 지원한다고 하여 알려드립니다. (version: 1.9.0)
-
미해결실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
상품 주문 Submit 시 오류 발생
[질문 템플릿]1. 강의 내용과 관련된 질문인가요? 예2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? 예3. 질문 잘하기 메뉴얼을 읽어보셨나요? 예[질문 내용]안녕하세요. 상품 주문 Submit 시 오류가 발생하여 문의드립니다. 오류를 살펴보니, CASCDAE와 관련된 오류라고 하더라구요.. 기존 Order 도메인 클래스의 member 부분이 이렇게 선언이 되어 있었는데@ManyToOne(fetch = LAZY) @JoinColumn(name = "member_id") private Member member; 오류를 보고 나서 cascade = CascadeType.ALL 옵션을 추가해주니까 오류 없이 동작을 하긴 하는데 이게 맞나 싶어서 문의드립니다..@ManyToOne(fetch = LAZY, cascade = CascadeType.ALL) @JoinColumn(name = "member_id") private Member member; 발생 오류입니다.인텔리제이 콘솔에 찍힌 로그이고요..org.hibernate.TransientPropertyValueException: object references an unsaved transient instance - save the transient instance before flushing : jpabook.jpashop.domain.Order.member -> jpabook.jpashop.domain.Member at org.hibernate.engine.spi.CascadingActions$8.noCascade(CascadingActions.java:379) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final] at org.hibernate.engine.internal.Cascade.cascade(Cascade.java:169) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final] at org.hibernate.event.internal.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:159) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final] at org.hibernate.event.internal.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:149) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final] at org.hibernate.event.internal.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:82) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final] at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final] at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:107) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final] at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1407) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final] at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:489) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final] at org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:3303) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final] at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:2438) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final] at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:449) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final] at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:183) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final] at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.access$300(JdbcResourceLocalTransactionCoordinatorImpl.java:40) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final] at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:281) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final] at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:101) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final] at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:562) ~[spring-orm-5.3.27.jar:5.3.27] at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:743) ~[spring-tx-5.3.27.jar:5.3.27] at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:711) ~[spring-tx-5.3.27.jar:5.3.27] at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:654) ~[spring-tx-5.3.27.jar:5.3.27] at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:407) ~[spring-tx-5.3.27.jar:5.3.27] at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119) ~[spring-tx-5.3.27.jar:5.3.27] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.27.jar:5.3.27] at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) ~[spring-aop-5.3.27.jar:5.3.27] at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:708) ~[spring-aop-5.3.27.jar:5.3.27] at jpabook.jpashop.service.OrderService$$EnhancerBySpringCGLIB$$c3aef6ec.order(<generated>) ~[classes/:na] at jpabook.jpashop.controller.OrderController.order(OrderController.java:42) ~[classes/:na] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na] at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na] at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) ~[spring-web-5.3.27.jar:5.3.27] at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150) ~[spring-web-5.3.27.jar:5.3.27] at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117) ~[spring-webmvc-5.3.27.jar:5.3.27] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895) ~[spring-webmvc-5.3.27.jar:5.3.27] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808) ~[spring-webmvc-5.3.27.jar:5.3.27] at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.3.27.jar:5.3.27] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1072) ~[spring-webmvc-5.3.27.jar:5.3.27] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:965) ~[spring-webmvc-5.3.27.jar:5.3.27] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.3.27.jar:5.3.27] at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) ~[spring-webmvc-5.3.27.jar:5.3.27] at javax.servlet.http.HttpServlet.service(HttpServlet.java:555) ~[tomcat-embed-core-9.0.74.jar:4.0.FR] at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.3.27.jar:5.3.27] at javax.servlet.http.HttpServlet.service(HttpServlet.java:623) ~[tomcat-embed-core-9.0.74.jar:4.0.FR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:209) ~[tomcat-embed-core-9.0.74.jar:9.0.74] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) ~[tomcat-embed-core-9.0.74.jar:9.0.74] at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51) ~[tomcat-embed-websocket-9.0.74.jar:9.0.74] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) ~[tomcat-embed-core-9.0.74.jar:9.0.74] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) ~[tomcat-embed-core-9.0.74.jar:9.0.74] at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.3.27.jar:5.3.27] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.27.jar:5.3.27] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) ~[tomcat-embed-core-9.0.74.jar:9.0.74] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) ~[tomcat-embed-core-9.0.74.jar:9.0.74] at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.3.27.jar:5.3.27] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.27.jar:5.3.27] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) ~[tomcat-embed-core-9.0.74.jar:9.0.74] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) ~[tomcat-embed-core-9.0.74.jar:9.0.74] at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.3.27.jar:5.3.27] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.27.jar:5.3.27] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) ~[tomcat-embed-core-9.0.74.jar:9.0.74] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) ~[tomcat-embed-core-9.0.74.jar:9.0.74] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:167) ~[tomcat-embed-core-9.0.74.jar:9.0.74] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90) ~[tomcat-embed-core-9.0.74.jar:9.0.74] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:481) ~[tomcat-embed-core-9.0.74.jar:9.0.74] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:130) ~[tomcat-embed-core-9.0.74.jar:9.0.74] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93) ~[tomcat-embed-core-9.0.74.jar:9.0.74] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) ~[tomcat-embed-core-9.0.74.jar:9.0.74] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) ~[tomcat-embed-core-9.0.74.jar:9.0.74] at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:389) ~[tomcat-embed-core-9.0.74.jar:9.0.74] at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63) ~[tomcat-embed-core-9.0.74.jar:9.0.74] at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:926) ~[tomcat-embed-core-9.0.74.jar:9.0.74] at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1791) ~[tomcat-embed-core-9.0.74.jar:9.0.74] at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52) ~[tomcat-embed-core-9.0.74.jar:9.0.74] at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) ~[tomcat-embed-core-9.0.74.jar:9.0.74] at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) ~[tomcat-embed-core-9.0.74.jar:9.0.74] at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-9.0.74.jar:9.0.74] at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na] 웹 브라우저에 출력된 에러 페이지입니다.Whitelabel Error PageThis application has no explicit mapping for /error, so you are seeing this as a fallback.Tue May 23 16:25:07 KST 2023There was an unexpected error (type=Internal Server Error, status=500).org.hibernate.TransientPropertyValueException: object references an unsaved transient instance - save the transient instance before flushing : jpabook.jpashop.domain.Order.member -> jpabook.jpashop.domain.Member; nested exception is java.lang.IllegalStateException: org.hibernate.TransientPropertyValueException: object references an unsaved transient instance - save the transient instance before flushing : jpabook.jpashop.domain.Order.member -> jpabook.jpashop.domain.Memberorg.springframework.dao.InvalidDataAccessApiUsageException: org.hibernate.TransientPropertyValueException: object references an unsaved transient instance - save the transient instance before flushing : jpabook.jpashop.domain.Order.member -> jpabook.jpashop.domain.Member; nested exception is java.lang.IllegalStateException: org.hibernate.TransientPropertyValueException: object references an unsaved transient instance - save the transient instance before flushing : jpabook.jpashop.domain.Order.member -> jpabook.jpashop.domain.Member at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:371) at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:235) at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:566) at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:743) at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:711) at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:654) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:407) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:708) at jpabook.jpashop.service.OrderService$$EnhancerBySpringCGLIB$$c3aef6ec.order(<generated>) at jpabook.jpashop.controller.OrderController.order(OrderController.java:42) 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.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1072) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:965) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) at javax.servlet.http.HttpServlet.service(HttpServlet.java:555) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:623) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:209) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:167) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:481) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:130) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:389) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:926) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1791) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52) at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.base/java.lang.Thread.run(Thread.java:834) Caused by: java.lang.IllegalStateException: org.hibernate.TransientPropertyValueException: object references an unsaved transient instance - save the transient instance before flushing : jpabook.jpashop.domain.Order.member -> jpabook.jpashop.domain.Member at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:151) at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:181) at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:188) at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1411) at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:489) at org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:3303) at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:2438) at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:449) at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:183) at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.access$300(JdbcResourceLocalTransactionCoordinatorImpl.java:40) at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:281) at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:101) at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:562) ... 60 more Caused by: org.hibernate.TransientPropertyValueException: object references an unsaved transient instance - save the transient instance before flushing : jpabook.jpashop.domain.Order.member -> jpabook.jpashop.domain.Member at org.hibernate.engine.spi.CascadingActions$8.noCascade(CascadingActions.java:379) at org.hibernate.engine.internal.Cascade.cascade(Cascade.java:169) at org.hibernate.event.internal.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:159) at org.hibernate.event.internal.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:149) at org.hibernate.event.internal.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:82) at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39) at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:107) at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1407) ... 69 more 작성한 코드도 올려두겠습니다.package jpabook.jpashop.controller; import jpabook.jpashop.domain.Member; import jpabook.jpashop.domain.item.Item; import jpabook.jpashop.service.ItemService; import jpabook.jpashop.service.MemberService; import jpabook.jpashop.service.OrderService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; import java.util.List; @Controller @RequiredArgsConstructor public class OrderController { private final OrderService orderService; private final MemberService memberService; private final ItemService itemService; @GetMapping("/order") public String createForm(Model model){ List<Member> members = memberService.findMembers(); List<Item> items = itemService.findItems(); model.addAttribute("members", members); model.addAttribute("items", items); return "order/orderForm"; } @PostMapping("/order") public String order(@RequestParam("memberId") Long memberId, @RequestParam("itemId") Long itemId, @RequestParam("count") int count){ orderService.order(memberId, itemId, count); return "redirect:/orders"; } }package jpabook.jpashop.service; import jpabook.jpashop.domain.Delivery; import jpabook.jpashop.domain.Member; import jpabook.jpashop.domain.Order; import jpabook.jpashop.domain.OrderItem; import jpabook.jpashop.domain.item.Item; import jpabook.jpashop.repository.ItemRepository; import jpabook.jpashop.repository.MemberRepository; import jpabook.jpashop.repository.OrderRepository; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @Service @Transactional(readOnly = true) @RequiredArgsConstructor public class OrderService { private final OrderRepository orderRepository; private final MemberRepository memberRepository; private final ItemRepository itemRepository; //주문 @Transactional public Long order(Long memberId, Long itemId, int count){ /* 엔티티 조회 */ //회원 조회 Member member = memberRepository.findOne(memberId); //상품 조회 Item item = itemRepository.findOne(itemId); //배송정보 생성 Delivery delivery = new Delivery(); delivery.setAddress(member.getAddress()); //주문상품 생성 OrderItem orderItem = OrderItem.createOrderItem(item, item.getPrice(), count); //주문 생성 Order order = Order.createOrder(member, delivery, orderItem); //주문 저장 orderRepository.save(order); //주문 식별자 반환 (ID) return order.getId(); } //주문 취소 @Transactional public void cancelOrder(Long orderId){ // 주문 엔티티 조회 Order order = orderRepository.findOne(orderId); //주문 취소 order.cancel(); } /*//검색 public List<Order> findOrders(OrderSearch orderSearch){ return orderRepository.findAll(orderSearch); }*/ }package jpabook.jpashop.domain; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; import org.aspectj.weaver.ast.Or; import javax.persistence.*; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; import static javax.persistence.FetchType.LAZY; @Entity @Table(name = "orders") @Getter @Setter @NoArgsConstructor(access = AccessLevel.PROTECTED) public class Order { @Id @GeneratedValue @Column(name="order_id") private Long id; @ManyToOne(fetch = LAZY) @JoinColumn(name = "member_id") private Member member; @OneToMany(mappedBy = "order", cascade = CascadeType.ALL) private List<OrderItem> orderItems = new ArrayList<>(); @OneToOne(fetch = LAZY, cascade = CascadeType.ALL) @JoinColumn(name = "delivery_id") private Delivery delivery; private LocalDateTime orderDate; @Enumerated(EnumType.STRING) private OrderStatus status; //주문상태 [ORDER, CANCEL] //== 연관관계 메서드 ==/ //== 양방향 연관관계에서의 편의 메서드 ==/ public void setMember(Member member){ this.member = new Member(); member.getOrders().add(this); } public void addOrderItem(OrderItem orderItem){ orderItems.add(orderItem); orderItem.setOrder(this); } public void setDelivery(Delivery delivery){ this.delivery = delivery; delivery.setOrder(this); } //==생성 메서드==// public static Order createOrder(Member member, Delivery delivery, OrderItem... orderItems){ Order order = new Order(); order.setMember(member); order.setDelivery(delivery); for (OrderItem orderItem : orderItems){ order.addOrderItem(orderItem); } order.setStatus(OrderStatus.ORDER); order.setOrderDate(LocalDateTime.now()); return order; } //==비즈니스 로직==// /* * 주문 취소 * */ public void cancel(){ if(delivery.getStatus() == DeliveryStatus.COMP){ throw new IllegalStateException("이미 배송 완료된 상품은 취소가 불가능합니다."); } this.setStatus(OrderStatus.CANCEL); for (OrderItem orderItem : orderItems){ orderItem.cancel(); } } //==조회 로직==// /** * 전체 주문 가격 조회 */ public int getTotalPrice(){ int totalPrice = 0; for (OrderItem orderItem : orderItems){ totalPrice += orderItem.getTotalPrice(); } return totalPrice; } } package jpabook.jpashop.domain; import lombok.Getter; import lombok.Setter; import javax.persistence.*; import java.util.ArrayList; import java.util.List; @Entity @Getter @Setter public class Member { @Id @GeneratedValue @Column(name = "member_id") private Long id; private String name; @Embedded private Address address; @OneToMany(mappedBy = "member") private List<Order> orders = new ArrayList<>(); }
-
해결됨[개념은 호옹~, 실습 빡] 스프링 부트, 입문!
19강 create POST 500 에러
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요.위를 실행하고 난 결과 콘솔창에서 아래 오류가 발생합니다. 구글링으로 오류를 찾아보니 ArticleForm에서 @Data나 @JsonAutoDetect(fieldVisibility = Visibility.ANY)를 작성하라고 하는데 둘다 적용해도 마찬가지로 위와 같은 오류가 발생합니다. 어떻게 해결해야하나요?
-
미해결스프링 시큐리티 OAuth2
코드를 가지고 at를 요청하는 걸 custom 할 수 있나요?
프론트에서 코드를 백으로 보내면 해당 코드로 at 를 받아서 유저 정보를 가져오고 싶은데 이렇게 하는게 가능한가요?
-
미해결스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
AOP 적용 중, 오류
글 작성후, 추가한 내용 ) TimeTraceAop에서 @Arount(!target .. ) 부분에 패키지명(service)까지 추가해서 hello.hellospring.service.SpringConfig 로 수정했더니 실행이 되었습니다 !!@Component @Aspect public class TimeTraceAop { @Around("execution(* hello.hellospring..*(..)) && !target(hello.hellospring.service.SpringConfig)") public Object execute(ProceedingJoinPoint joinPoint) throws Throwable { .... } } 왜 패키지명을 추가했더니, 정상적으로 작동되는걸까요??SpringConfig를 제외하고 execution하라는 것 같은데, 경로를 못찾는거랑 관계가 있나요?? 저는 Error creating bean with name 'projectingArgumentResolverBeanPostProcessor 메시지를 보고스프링 빈이 안만들어져서 오류가 나는줄 알았거든요,,!! ㅜㅜㅎㅎㅎ 안녕하세요!AOP 적용 중에 아래와 같은 오류가 뜹니다근데 아무리 구글링 해봐도.. 이유를 모르겠습니다 Error creating bean with name 'projectingArgumentResolverBeanPostProcessor이 부분을 보고 projectingArgumentResolverBeanPostProcessor 빈이 안만들어졌다는건 알겠는데정확히 어느 부분 때문인지,그리고 해결방법이 어떻게되는지를 모르겠습니다 에러메시지 "C:\Program Files\Java\jdk-11\bin\java.exe" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2023.1.2\lib\idea_rt.jar=51347:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2023.1.2\bin" -Dfile.encoding=UTF-8 -classpath C:\study2\hello-spring\hello-spring\out\production\classes;C:\study2\hello-spring\hello-spring\out\production\resources;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-thymeleaf\2.7.11\e2d7ab403b2ab254e7706755a0158452e7a85463\spring-boot-starter-thymeleaf-2.7.11.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-web\2.7.11\c23ca827c1d5cf45d70f4b5204a9b889ec5d3b24\spring-boot-starter-web-2.7.11.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-data-jpa\2.7.11\43268b1cdb2711aef4563bc3ac1d2f8936527cd9\spring-boot-starter-data-jpa-2.7.11.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter\2.7.11\3b655d0b1817b5f92301d9da5eb9f8f8f37ded6a\spring-boot-starter-2.7.11.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.thymeleaf\thymeleaf-spring5\3.0.15.RELEASE\7170e1bcd1588d38c139f7048ebcc262676441c3\thymeleaf-spring5-3.0.15.RELEASE.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.thymeleaf.extras\thymeleaf-extras-java8time\3.0.4.RELEASE\36e7175ddce36c486fff4578b5af7bb32f54f5df\thymeleaf-extras-java8time-3.0.4.RELEASE.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-json\2.7.11\9f47d076fd9d1b2acec8d189e6413d3c5d270d30\spring-boot-starter-json-2.7.11.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-tomcat\2.7.11\d9d6f0e0aacd095bcae08bfbb72404ec114238e2\spring-boot-starter-tomcat-2.7.11.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.springframework\spring-webmvc\5.3.27\8beabbb0cb64c448b39df790b62e342245ee7971\spring-webmvc-5.3.27.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.springframework\spring-web\5.3.27\a51c45a8602052a2a90f7e645a47ba8df1547795\spring-web-5.3.27.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-aop\2.7.11\9b153237690b028c57f443aad49144e62dd2a8b5\spring-boot-starter-aop-2.7.11.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-jdbc\2.7.11\b502fe4cbdf3ec3b97d8cfd093becac0225eba48\spring-boot-starter-jdbc-2.7.11.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\jakarta.transaction\jakarta.transaction-api\1.3.3\c4179d48720a1e87202115fbed6089bdc4195405\jakarta.transaction-api-1.3.3.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\jakarta.persistence\jakarta.persistence-api\2.2.3\8f6ea5daedc614f07a3654a455660145286f024e\jakarta.persistence-api-2.2.3.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.hibernate\hibernate-core\5.6.15.Final\ab14b7cef1fdff654ca81923048a6034d6c7cfa7\hibernate-core-5.6.15.Final.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.springframework.data\spring-data-jpa\2.7.11\3c97d46f1a4c664fd65b302bf0e0391cfebc0ce8\spring-data-jpa-2.7.11.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.springframework\spring-aspects\5.3.27\d6311337bd1eb60cb7da6f064c97c4b22a16497\spring-aspects-5.3.27.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-autoconfigure\2.7.11\d7b1b3a4c494e240ad0a53b2d6661982d7c9ddac\spring-boot-autoconfigure-2.7.11.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot\2.7.11\f99d0b98ecd8de1400dc47d00194202e9be5a16e\spring-boot-2.7.11.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-logging\2.7.11\b0d3e13291ecd5014d3c5f8818f50620f7b1f1fd\spring-boot-starter-logging-2.7.11.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\jakarta.annotation\jakarta.annotation-api\1.3.5\59eb84ee0d616332ff44aba065f3888cf002cd2d\jakarta.annotation-api-1.3.5.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.springframework\spring-core\5.3.27\ff5e35f2d4f72d22c476ff9b7bce1de25c980ebd\spring-core-5.3.27.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.yaml\snakeyaml\1.30\8fde7fe2586328ac3c68db92045e1c8759125000\snakeyaml-1.30.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.thymeleaf\thymeleaf\3.0.15.RELEASE\13e3296a03d8a597b734d832ed8656139bf9cdd8\thymeleaf-3.0.15.RELEASE.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.slf4j\slf4j-api\1.7.36\6c62681a2f655b49963a5983b8b0950a6120ae14\slf4j-api-1.7.36.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.datatype\jackson-datatype-jsr310\2.13.5\8ba3b868e81d7fc6ead686bd2353859b111d9eaf\jackson-datatype-jsr310-2.13.5.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.module\jackson-module-parameter-names\2.13.5\a401a99e7a45450fd3ef76e82ba39005fd1a8c22\jackson-module-parameter-names-2.13.5.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.datatype\jackson-datatype-jdk8\2.13.5\1278f38160812811c56eb77f67213662ed1c7a2e\jackson-datatype-jdk8-2.13.5.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-databind\2.13.5\aa95e46dbc32454f3983221d420e78ef19ddf844\jackson-databind-2.13.5.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.apache.tomcat.embed\tomcat-embed-websocket\9.0.74\a38c3bf842eab8112809bbdb836441db423076bf\tomcat-embed-websocket-9.0.74.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.apache.tomcat.embed\tomcat-embed-core\9.0.74\5afe5c4cfc8e78c395207d6abcc98666b508ec0c\tomcat-embed-core-9.0.74.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.apache.tomcat.embed\tomcat-embed-el\9.0.74\f7b97a38cc7dee092fd58a8df80788284b588566\tomcat-embed-el-9.0.74.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.springframework\spring-context\5.3.27\251162aa2fe5cb374a482ae87fa6e8e8e747d72\spring-context-5.3.27.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.springframework\spring-aop\5.3.27\ecae2962d53c587fd0e405cd60dc8415d1b9e12d\spring-aop-5.3.27.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.springframework\spring-beans\5.3.27\46e7d917551ffcc0a104fd971d1fa207b30d7761\spring-beans-5.3.27.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.springframework\spring-expression\5.3.27\6225619970e8376df5c3d777610d9d03b977063b\spring-expression-5.3.27.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.aspectj\aspectjweaver\1.9.7\158f5c255cd3e4408e795b79f7c3fbae9b53b7ca\aspectjweaver-1.9.7.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.springframework\spring-jdbc\5.3.27\c96414a7531595d9c7d2addee132b362fa5ef65f\spring-jdbc-5.3.27.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\com.zaxxer\HikariCP\4.0.3\107cbdf0db6780a065f895ae9d8fbf3bb0e1c21f\HikariCP-4.0.3.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.hibernate.common\hibernate-commons-annotations\5.1.2.Final\e59ffdbc6ad09eeb33507b39ffcf287679a498c8\hibernate-commons-annotations-5.1.2.Final.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.jboss.logging\jboss-logging\3.4.3.Final\c4bd7e12a745c0e7f6cf98c45cdcdf482fd827ea\jboss-logging-3.4.3.Final.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\net.bytebuddy\byte-buddy\1.12.23\d470526e8c4566c04e9ae5d3ccb62d1a7aa58986\byte-buddy-1.12.23.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\antlr\antlr\2.7.7\83cd2cd674a217ade95a4bb83a8a14f351f48bd0\antlr-2.7.7.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.jboss\jandex\2.4.2.Final\1e1c385990b258ff1a24c801e84aebbacf70eb39\jandex-2.4.2.Final.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\com.fasterxml\classmate\1.5.1\3fe0bed568c62df5e89f4f174c101eab25345b6c\classmate-1.5.1.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.glassfish.jaxb\jaxb-runtime\2.3.8\c90a335a07c60db986f29d35b0f8ac0a18f0f989\jaxb-runtime-2.3.8.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.springframework\spring-orm\5.3.27\80823b39c7fe25ec825e7e13cb7ac0053fada349\spring-orm-5.3.27.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.springframework.data\spring-data-commons\2.7.11\bcc82d39f81645c2ace67ce254324819e85958a9\spring-data-commons-2.7.11.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.springframework\spring-tx\5.3.27\be6e6752ad18f0944af21c3da8987b6506e13c53\spring-tx-5.3.27.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\ch.qos.logback\logback-classic\1.2.12\d4dee19148dccb177a0736eb2027bd195341da78\logback-classic-1.2.12.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.apache.logging.log4j\log4j-to-slf4j\2.17.2\17dd0fae2747d9a28c67bc9534108823d2376b46\log4j-to-slf4j-2.17.2.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.slf4j\jul-to-slf4j\1.7.36\ed46d81cef9c412a88caef405b58f93a678ff2ca\jul-to-slf4j-1.7.36.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.springframework\spring-jcl\5.3.27\9698ea7d5361b5e3a27ed08beb7770279bd2397\spring-jcl-5.3.27.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.attoparser\attoparser\2.0.5.RELEASE\a93ad36df9560de3a5312c1d14f69d938099fa64\attoparser-2.0.5.RELEASE.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.unbescape\unbescape\1.1.6.RELEASE\7b90360afb2b860e09e8347112800d12c12b2a13\unbescape-1.1.6.RELEASE.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-annotations\2.13.5\136f77ab424f302c9e27230b4482e8000e142edf\jackson-annotations-2.13.5.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-core\2.13.5\d07c97d3de9ea658caf1ff1809fd9de930a286a\jackson-core-2.13.5.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\jakarta.xml.bind\jakarta.xml.bind-api\2.3.3\48e3b9cfc10752fba3521d6511f4165bea951801\jakarta.xml.bind-api-2.3.3.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.glassfish.jaxb\txw2\2.3.8\66e0297f1196f0d15a776e699de1b8e6ac5d44dd\txw2-2.3.8.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\com.sun.istack\istack-commons-runtime\3.0.12\cbbe1a62b0cc6c85972e99d52aaee350153dc530\istack-commons-runtime-3.0.12.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\ch.qos.logback\logback-core\1.2.12\1d8e51a698b138065d73baefb4f94531faa323cb\logback-core-1.2.12.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\org.apache.logging.log4j\log4j-api\2.17.2\f42d6afa111b4dec5d2aea0fe2197240749a4ea6\log4j-api-2.17.2.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\com.h2database\h2\2.1.214\d5c2005c9e3279201e12d4776c948578b16bf8b2\h2-2.1.214.jar;C:\Users\Jung\.gradle\caches\modules-2\files-2.1\com.sun.activation\jakarta.activation\1.2.2\74548703f9851017ce2f556066659438019e7eb5\jakarta.activation-1.2.2.jar hello.hellospring.HelloSpringApplication . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.7.11) 2023-05-23 10:58:10.603 INFO 9292 --- [ main] h.hellospring.HelloSpringApplication : Starting HelloSpringApplication using Java 11.0.18 on DESKTOP-70N8DCL with PID 9292 (C:\study2\hello-spring\hello-spring\out\production\classes started by Jung in C:\study2\hello-spring\hello-spring) 2023-05-23 10:58:10.611 INFO 9292 --- [ main] h.hellospring.HelloSpringApplication : No active profile set, falling back to 1 default profile: "default" 2023-05-23 10:58:11.973 INFO 9292 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode. 2023-05-23 10:58:12.110 INFO 9292 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 114 ms. Found 1 JPA repository interfaces. 2023-05-23 10:58:12.862 WARN 9292 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'projectingArgumentResolverBeanPostProcessor' defined in class path resource [org/springframework/data/web/config/ProjectingArgumentResolverRegistrar.class]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: warning no match for this type name: hello.hellospring.SpringConfig [Xlint:invalidAbsoluteTypeName] 2023-05-23 10:58:12.879 INFO 9292 --- [ main] ConditionEvaluationReportLoggingListener : Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2023-05-23 10:58:12.928 ERROR 9292 --- [ main] o.s.boot.SpringApplication : Application run failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'projectingArgumentResolverBeanPostProcessor' defined in class path resource [org/springframework/data/web/config/ProjectingArgumentResolverRegistrar.class]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: warning no match for this type name: hello.hellospring.SpringConfig [Xlint:invalidAbsoluteTypeName] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:537) ~[spring-beans-5.3.27.jar:5.3.27] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.27.jar:5.3.27] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.27.jar:5.3.27] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.27.jar:5.3.27] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:213) ~[spring-beans-5.3.27.jar:5.3.27] at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:270) ~[spring-context-5.3.27.jar:5.3.27] at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:764) ~[spring-context-5.3.27.jar:5.3.27] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:567) ~[spring-context-5.3.27.jar:5.3.27] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) ~[spring-boot-2.7.11.jar:2.7.11] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:731) ~[spring-boot-2.7.11.jar:2.7.11] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) ~[spring-boot-2.7.11.jar:2.7.11] at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) ~[spring-boot-2.7.11.jar:2.7.11] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303) ~[spring-boot-2.7.11.jar:2.7.11] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292) ~[spring-boot-2.7.11.jar:2.7.11] at hello.hellospring.HelloSpringApplication.main(HelloSpringApplication.java:10) ~[classes/:na] Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: warning no match for this type name: hello.hellospring.SpringConfig [Xlint:invalidAbsoluteTypeName] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:628) ~[spring-beans-5.3.27.jar:5.3.27] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.27.jar:5.3.27] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.27.jar:5.3.27] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.27.jar:5.3.27] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.27.jar:5.3.27] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.27.jar:5.3.27] at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:410) ~[spring-beans-5.3.27.jar:5.3.27] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352) ~[spring-beans-5.3.27.jar:5.3.27] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195) ~[spring-beans-5.3.27.jar:5.3.27] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[spring-beans-5.3.27.jar:5.3.27] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.27.jar:5.3.27] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.27.jar:5.3.27] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.27.jar:5.3.27] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.27.jar:5.3.27] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:213) ~[spring-beans-5.3.27.jar:5.3.27] at org.springframework.aop.framework.autoproxy.BeanFactoryAdvisorRetrievalHelper.findAdvisorBeans(BeanFactoryAdvisorRetrievalHelper.java:91) ~[spring-aop-5.3.27.jar:5.3.27] at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findCandidateAdvisors(AbstractAdvisorAutoProxyCreator.java:111) ~[spring-aop-5.3.27.jar:5.3.27] at org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator.findCandidateAdvisors(AnnotationAwareAspectJAutoProxyCreator.java:92) ~[spring-aop-5.3.27.jar:5.3.27] at org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator.shouldSkip(AspectJAwareAdvisorAutoProxyCreator.java:101) ~[spring-aop-5.3.27.jar:5.3.27] at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessBeforeInstantiation(AbstractAutoProxyCreator.java:255) ~[spring-aop-5.3.27.jar:5.3.27] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:1160) ~[spring-beans-5.3.27.jar:5.3.27] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:1135) ~[spring-beans-5.3.27.jar:5.3.27] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:531) ~[spring-beans-5.3.27.jar:5.3.27] ... 14 common frames omitted Caused by: java.lang.IllegalArgumentException: warning no match for this type name: hello.hellospring.SpringConfig [Xlint:invalidAbsoluteTypeName] at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:319) ~[aspectjweaver-1.9.7.jar:na] at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:227) ~[spring-aop-5.3.27.jar:5.3.27] at org.springframework.aop.aspectj.AspectJExpressionPointcut.obtainPointcutExpression(AspectJExpressionPointcut.java:198) ~[spring-aop-5.3.27.jar:5.3.27] at org.springframework.aop.aspectj.AspectJExpressionPointcut.getClassFilter(AspectJExpressionPointcut.java:177) ~[spring-aop-5.3.27.jar:5.3.27] at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:226) ~[spring-aop-5.3.27.jar:5.3.27] at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:289) ~[spring-aop-5.3.27.jar:5.3.27] at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:321) ~[spring-aop-5.3.27.jar:5.3.27] at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:128) ~[spring-aop-5.3.27.jar:5.3.27] at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:97) ~[spring-aop-5.3.27.jar:5.3.27] at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:78) ~[spring-aop-5.3.27.jar:5.3.27] at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:341) ~[spring-aop-5.3.27.jar:5.3.27] at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:293) ~[spring-aop-5.3.27.jar:5.3.27] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:455) ~[spring-beans-5.3.27.jar:5.3.27] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1808) ~[spring-beans-5.3.27.jar:5.3.27] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.27.jar:5.3.27] ... 36 common frames omitted Process finished with exit code 1 TimeTraceAoppackage hello.hellospring.aop; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.springframework.stereotype.Component; @Component @Aspect public class TimeTraceAop { @Around("execution(* hello.hellospring..*(..)) && !target(hello.hellospring.SpringConfig)") public Object execute(ProceedingJoinPoint joinPoint) throws Throwable{ long start = System.currentTimeMillis(); System.out.println("START: " + joinPoint.toString()); try{ return joinPoint.proceed(); } finally { long finish = System.currentTimeMillis(); long timeMs = finish - start; System.out.println("END: " + joinPoint.toString() + " " + timeMs + "ms"); } } } application.propertiesspring.datasource.url=jdbc:h2:tcp://localhost/~/test spring.datasource.driver-class-name=org.h2.Driver spring.datasource.username=sa spring.jpa.show-sql=true spring.jpa.hibernate.ddl-auto=none spring.main.allow-bean-definition-overriding=true SpringConfigpackage hello.hellospring.service; import hello.hellospring.aop.TimeTraceAop; import hello.hellospring.repository.JpaMemberRepository; import hello.hellospring.repository.MemberRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration public class SpringConfig { private final MemberRepository memberRepository; @Autowired public SpringConfig(MemberRepository memberRepository) { this.memberRepository = memberRepository; } @Bean public MemberService memberService(){ //return new MemberService(memberRepository()); // 이 로직을 호출해서 등록해줌 // memberService는 스프링 빈에 있는 memberRepository를 엮ㅇㅓ줘야 함. return new MemberService(memberRepository); } @Bean public TimeTraceAop timeTraceAop() { return new TimeTraceAop(); } /* @Bean public MemberRepository memberRepository(){ // return new JdbcMemberRepository(dataSource); // return new MemoryMemberRepository(); // return new JdbcTemplateMemberRepository(dataSource); // return new JpaMemberRepository(em); } */ } MemberServicepackage hello.hellospring.service; import hello.hellospring.domain.Member; import hello.hellospring.repository.MemberRepository; import hello.hellospring.repository.MemoryMemberRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.List; import java.util.Optional; @Transactional public class MemberService { private final MemberRepository memberRepository; // MemberRepository를 내가 직접 생성하는게 아니라, 외부에서 넣어주도록 바꿔주기 // => dependency Injection 이라고 함. (DI) @Autowired public MemberService(MemberRepository memberRepository) { this.memberRepository = memberRepository; } /** * 회원 가입 */ public Long join(Member member) { // 같은 이름이 있는 중복 회원은 등록되지 않게 하는 비즈니스 로직 Long start = System.currentTimeMillis(); try { validateDuplicateMember(member); // 중복 회원 검증 memberRepository.save(member); // 검증 통과하면 저장 return member.getId(); } finally { long finish = System.currentTimeMillis(); long timeMs = finish - start; System.out.println("join = " + timeMs + "ms"); } } private void validateDuplicateMember(Member member) { memberRepository.findByName(member.getName()) // findByName을 하면 그 결과는 Optional. .ifPresent(m -> { throw new IllegalStateException("이미 존재하는 회원입니다."); // null이 아니라면, 위의 로직이 동작. 기존에는 if != null 이었겠지만 Optional로 감싸서 가능함 }); } /** * 전체 회원 조회 */ public List<Member> findMembers() { Long start = System.currentTimeMillis(); try { return memberRepository.findAll(); } finally { long finish = System.currentTimeMillis(); long timeMs = finish - start; System.out.println("findMembers " + timeMs + "ms"); } } public Optional<Member> findOne(Long memberId){ return memberRepository.findById(memberId); } }
-
미해결스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
테스트케이스 9:32 @Test
[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예/아니오)예2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오)예3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오)음..아니요[질문 내용]여기에 질문 내용을 남겨주세요.강의 9:32부분에서 에러가 나야되는데 spring2로 member1 이니까요,근데 저는 spring1도 초록불 save고spring2에서도 초록불이고심지어 spring21이여도 초록불이에요그 전까지는 강의 대로 결과가 나왔는데이건 아무리 바꿔도 결과가 강의랑 다르네요...어떻게 해야 에러가 뜰까요?????????????????save가 되면 안되는거잖아요....? MemoryMemberRepositoryTest 코드도 복붙해여주석은 신경쓰지말고 봐주세여; 한곳 이해못한것있는데 제가 설명을 못알아들어서요 확인되시면 설명도 추가적으로 부탁드릴래요package hello.hellospring.repository;import hello.hellospring.domain.Member;import org.assertj.core.api.Assertions;import org.junit.jupiter.api.Test;import static org.assertj.core.api.Assertions.*;class MemoryMemberRepositoryTest {MemberRepository repository = new MemoryMemberRepository();@Testpublic void save() {Member member = new Member();member.setName("spring");repository.save(member);Member result = repository.findById(member.getId()).get(); //get:바로꺼내는게좋지는않지만테스트니ok//System.out.println("result = " + (result == member)); //이렇게 가져올수없으니assertThat(member).isEqualTo(result); //option + enter}@Testpublic void findByName() {Member member1 = new Member();member1.setName("spring1");repository.save(member1);Member member2 = new Member(); //shift + F6 중복이름 고칠때 같이 고쳐짐member2.setName("spring2");repository.save(member2);Member result = repository.findByName("spring1").get(); //한번까서?보낸다고요??이해못했음 <= 아, 이부분도 설명해주시면 좋을것같아용 히히assertThat(result).isEqualTo(member1);}}
-
미해결Spring Cloud로 개발하는 마이크로서비스 애플리케이션(MSA)
카프카 커넥트 재실행시 저는 my-sink-connect와 my-source-connect가 안남는데
유지하는 설정이 따로있을까요?
-
해결됨자바와 스프링 부트로 생애 최초 서버 만들기, 누구나 쉽게 개발부터 배포까지! [서버 개발 올인원 패키지]
컨트롤러 반환 타입 질문입니다.
안녕하세요, 강사님. 컨트롤러 코드 관련 질문입니다.작성한 코드는 컨트롤러의 메소드 반환 타입을 void로 해서 아무것도 반환하지 않는데요, 만약 postmapping 관련 메소드 작성 시, 작성한 게시글의 id값을 반환해주는 코드와 큰 차이가 있을까요?그리고 찾아보던 중, ResponseEntity를 사용해서 반환해주는 메소드를 보았는데, 메소드의 반환 타입에 따라 기능에 큰 차이가 있는지, 아니면 API 명세의 차이만 있고 기능에는 크게 차이가 없는지 궁금합니다!
-
미해결실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
양방향 편의 메서드에서 필드에 직접 접근하는 문제
[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예)[질문 내용]본 강의 마지막 부분에 연관관계 편의 메서드를 만드는 부분이 있는데, 필드에 직접 접근하여 설정하는 내용이 있습니다. 예를들어 this.child.add(child);this.member = member;와 같은 코드들이 문제가 되지는 않겠지만 유지보수 측면에서 안 좋은 영향을 끼치는 것 같아서this.getChild().add(child);this.setMember(member);와 같이 리팩토링하는 것이 좋지 않나 궁금합니다.
-
해결됨실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발
memberServiceTest 회원가입 NullPointerException 오류
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요.1. 강의 내용과 관련된 질문을 남겨주세요.2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요.(자주 하는 질문 링크: https://bit.ly/3fX6ygx)3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요.(질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG)질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요.=========================================[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예/아니오)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오)[질문 내용]여기에 질문 내용을 남겨주세요.안녕하세요.강의를 한 번 완주한 후 개별적으로 예제와 다르게 다시 공부하고 있는데 오류가 나서요..ㅜㅜhttps://drive.google.com/file/d/1Fe9hZbwSCKFYyQtmj_TU2Sl9VwqeXCsO/view?usp=sharing무엇 때문에 오류가 났는지 알 수 있을까요??
-
해결됨스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
[개별 테스트 코드 실행] IntelliJ Gutter Icon 나타나지 않습니다.
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요.1. 강의 내용과 관련된 질문을 남겨주세요.2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요.(자주 하는 질문 링크: https://bit.ly/3fX6ygx)3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요.(질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG)질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요.=========================================[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예/아니오)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오)[질문 내용][질문 : IntelliJ gutter Icon]1. 내용 : 개별 메서드 실행을 -> gutter icon을 눌러서 하고 싶은데. 보이지 않습니다. 2. 시도 : Settings -> Editor -> General -> Gutter Icons 선택3. 결과 : 여전히 Gutter Icon 안나옴
-
미해결실전! 스프링 데이터 JPA
MemberTest
MemberTest에서 changeTeam메소드를 테스트 해보고 싶어서 추가로 코딩해서 실행해보았습니다.근데 System.out.println(member1.getTeam().getName()); System.out.println(teamB.getMembers().stream().collect(Collectors.toList()));위의 코드에는 반영이 되는 데 h2에 select문으로 member를 쿼리해보면 반영이 안되어있더라구요. 제가 공부한바로는 em.flush(), em.close 하면 db에 반영되는 걸로 이해하고 있는데... 잘못이해하고 있는 건가요??
-
해결됨[개념은 호옹~, 실습 빡] 스프링 부트, 입문!
19강 JSON create 메서드 질문이여!!
package com.example.firstproject.api;import com.example.firstproject.dto.ArticleForm;import com.example.firstproject.entity.Article;import com.example.firstproject.repository.ArticleRepository;// import lombok.AllArgsConstructor;// import lombok.NoArgsConstructor;// import lombok.RequiredArgsConstructor;import org.springframework.web.bind.annotation.*;import java.util.List;@RestControllerpublic class ArticleApiController {private ArticleRepository articleRepository;private ArticleForm dto;@GetMapping("/api/articles")public List<Article> index() {return articleRepository.findAll();}@GetMapping("/api/articles/{id}")public Article index(@PathVariable Long id) {return articleRepository.findById(id).orElse(null);}@PostMapping("/api/articles")public Article create(@RequestBody ArticleForm dto) {Article article = dto.toEntity();return articleRepository.save(article);}} PostMapping하고 있는데, Talend API Tester에서 아래와 같이 실행시키면 안돼여에러메시지는 아래와 같습니다Cannot invoke "com.example.firstproject.repository.ArticleRepository.save(Object)" because "this.articleRepository" is null라고 떠여... 그래서 ArticleRepository를 확인해보면ArticleRepository는package com.example.firstproject.repository;import com.example.firstproject.entity.Article;import org.springframework.data.repository.CrudRepository;import java.util.ArrayList;public interface ArticleRepository extends CrudRepository<Article, Long> {@OverrideArrayList<Article> findAll();}으로 썜이랑 똑같이 작성했어요 쌤.... 제가 뭘 잘못 했나여............뭘 고치면 되나여......... 살려주십셔.,,,,,,,,,,,,,.