inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

묻고 답해요

173만명의 커뮤니티!! 함께 토론해봐요.

출력(전반전-정수)

미해결

나도코딩의 자바 기본편 - 풀코스 (20시간)

정수 3자리마다 콤마가 찍히는 원리를 답변 받고 싶습니다 ㅠㅠ

  • oop
  • java
문수 댓글 2 좋아요 -1 조회수 414

컨트롤러를 인식 못하는거같습니다. 404에러

미해결

스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술

학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요. 1. 강의 내용과 관련된 질문을 남겨주세요. 2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요. (자주 하는 질문 링크: https://bit.ly/3fX6ygx) 3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요. (질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG) 질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요. ========================================= [질문 템플릿] 1. 강의 내용과 관련된 질문인가요? 예 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오) 예 3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오) 예 [질문 내용] 여기에 질문 내용을 남겨주세요. 컨트롤러를 인식하지 못하는거같습니다 무슨 문제가있는지 궁금합니다

  • spring-boot
  • java
  • MVC
  • spring
liilaa 댓글 1 좋아요 0 조회수 694

veiw spring! 가 안되요

해결됨

스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술

학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요. 1. 강의 내용과 관련된 질문을 남겨주세요. 2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요. (자주 하는 질문 링크: https://bit.ly/3fX6ygx) 3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요. (질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG) 질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요. ========================================= [질문 템플릿] 1. 강의 내용과 관련된 질문인가요? (예/아니오) 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오) 3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오) [질문 내용] 여기에 질문 내용을 남겨주세요.

  • MVC
  • spring-boot
  • java
  • spring
오상수 댓글 1 좋아요 0 조회수 468

basename 질문드립니다.

미해결

스프링 MVC 2편 - 백엔드 웹 개발 활용 기술

만약 basename을 messages가 아닌 임의로 등록하게 되면 다른 언어 정보 파일들도 파일명_나라명.properties로 설정하면 되나요?

  • MVC
  • spring
차노쓰 댓글 1 좋아요 0 조회수 546

임베티드 타입에 대해 질문있습니다.

미해결

자바 ORM 표준 JPA 프로그래밍 - 기본편

7분44초에 임베디드 타입에서 같은 객체를 사용하여 저장하고 setter를 통해서 값을 수정하게 되면 같은 객체의 인스턴스를 사용하기 때문에 값이 member1과 member2가 둘 다 바뀐다고 하셔서 제가 테스트를 해봤습니다. 같은 메서드에서 member1과 member2를 같은 address 객체를 사용해서 저장한 건 똑같은데 다른 메서드에서 아래에 코드 처럼 member1을 찾아와서 city를 수정하니 member2는 수정이 안된 것을 확인하였습니다. 이것은 다른 트랜잭션을 사용하기 때문에 같은 인스턴스를 공유하고 있지 않은 건가요? Member member = em.find(Member.class, 1L); member.getHomeAddress().setCity("city");

  • java
  • JPA
댓글 1 좋아요 0 조회수 401

requests.parm 이 오류나요

미해결

스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술

학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요. 1. 강의 내용과 관련된 질문을 남겨주세요. 2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요. (자주 하는 질문 링크: https://bit.ly/3fX6ygx) 3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요. (질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG) 질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요. ========================================= [질문 템플릿] 1. 강의 내용과 관련된 질문인가요? (예/아니오) 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오) 3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오) [질문 내용] controller 에서 만들었는데 이렇게 오류나는데 어떻게 해야되나요?

  • MVC
  • java
  • spring-boot
  • spring
오상수 댓글 1 좋아요 0 조회수 382

Controller를 인식하지 못하는것같습니다

해결됨

스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술

새로운 프로젝트를 만들었는데 Controller를 인식하지 못해서 그런지 404 error만 나옵니다ㅜㅜ. SpringBootApplication의 하위 폴더에 Controller를 만들었고 @Controller 어노테이션도 붙여줬는데 인식하지 못해서 가장 기본적인 "hello"를 못찍고 있습니다ㅜㅜ. 너무 기본적인 질문인데 해결하지 못해서 올리게되었습니다.

  • spring-boot
  • MVC
  • spring
  • java
황규철 댓글 1 좋아요 0 조회수 461

Ajax 인증시 인가코드가 발급 되지 않는 원인 문의

해결됨

스프링 시큐리티 OAuth2

Spring Authorization 1.0,1 기반으로 개발을 하고 있습니다. 인가코드를 발급 할떄 FormLogin 기본 설정을 사용하면 인가코드가 발급이 되는데 Ajax 로 로그인을 하면 인가코드가 발급되지 않고 있습니다. 디버깅을 해보면 로그인인 후 OAuth2AuthorizationEndpointFilter 는 실행되는데 @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { if (!this.authorizationEndpointMatcher.matches(request)) { filterChain.doFilter(request, response); return; } try { Authentication authentication = this.authenticationConverter.convert(request); if (authentication instanceof AbstractAuthenticationToken) { ((AbstractAuthenticationToken) authentication) .setDetails(this.authenticationDetailsSource.buildDetails(request)); } Authentication authenticationResult = this.authenticationManager.authenticate(authentication); if (!authenticationResult.isAuthenticated()) { // If the Principal (Resource Owner) is not authenticated then // pass through the chain with the expectation that the authentication process // will commence via AuthenticationEntryPoint filterChain.doFilter(request, response); return; } if (authenticationResult instanceof OAuth2AuthorizationConsentAuthenticationToken) { if (this.logger.isTraceEnabled()) { this.logger.trace("Authorization consent is required"); } sendAuthorizationConsent(request, response, (OAuth2AuthorizationCodeRequestAuthenticationToken) authentication, (OAuth2AuthorizationConsentAuthenticationToken) authenticationResult); return; } this.authenticationSuccessHandler.onAuthenticationSuccess( request, response, authenticationResult); } catch (OAuth2AuthenticationException ex) { if (this.logger.isTraceEnabled()) { this.logger.trace(LogMessage.format("Authorization request failed: %s", ex.getError()), ex); } this.authenticationFailureHandler.onAuthenticationFailure(request, response, ex); } } FormLogin 적용시에는 authenticationResult의 principal 에 UsernamePasswordAuthenticationToken이 설정되어 인가 코드가 정상적으로 발급되는데 AjaxLogin 적용시에는 authenticationResult의 principal 에 AnonymousAuthenticationToken이 설정되어 인가 코드가 정상적으로 발급되지 않고 403 예외가 발생합니다. AuthenticationProvider 구현체에서는 정상적으로 토큰을 저장하고 있습니다. AuthenticationProvider 구현체 소스 @Component @RequiredArgsConstructor public class CustomAuthenticationProvider implements AuthenticationProvider { private final CustomUserDetailsService customUserDetailsService; private final PasswordEncoder passwordEncoder; @Override public Authentication authenticate(Authentication authentication) throws AuthenticationException { if(authentication == null){ throw new InternalAuthenticationServiceException("Authentication is null"); } LoginRequestDto loginRequestDto = (LoginRequestDto)authentication.getPrincipal(); String password = loginRequestDto.getLoginPassword(); UserAdapter userAdapter = (UserAdapter) customUserDetailsService.loadUserByLoinRequestDto(loginRequestDto); if (!passwordEncoder.matches(password, userAdapter.getCurrentUser().getLoginPwd())) { throw new BadCredentialsException("BadCredentialsException"); } CustomAuthenticationToken result = CustomAuthenticationToken.authenticated(userAdapter.getCurrentUser(), authentication.getCredentials(), userAdapter.getAuthorities()); result.setDetails(authentication.getDetails()); return result; } @Override public boolean supports(Class<?> authentication) { return CustomAuthenticationToken.class.isAssignableFrom(authentication); } } 이외 Custom 소스 Spring Security 설정 @EnableWebSecurity @RequiredArgsConstructor @Configuration public class DefaultSecurityConfig { private final CustomAuthenticationProvider customAuthenticationProvider; // private final CustomUserDetailsService customUserDetailsService; @Bean public AuthenticationManager authenticationManager(AuthenticationConfiguration authenticationConfiguration) throws Exception { return authenticationConfiguration.getAuthenticationManager(); } @Bean public CustomAuthenticationProcessingFilter customAuthenticationProcessingFilter() throws Exception { CustomAuthenticationProcessingFilter filter = new CustomAuthenticationProcessingFilter(); // filter.setAuthenticationManager(authenticationManager(null)); filter.setAuthenticationManager(new ProviderManager(customAuthenticationProvider)); // filter.setAuthenticationSuccessHandler(customAuthenticationSuccessHandler()); // filter.setAuthenticationFailureHandler(customAuthenticationFailureHandler()); return filter; } // @formatter:off @Bean SecurityFilterChain defaultSecurityFilterChain(HttpSecurity http) throws Exception { http .authorizeHttpRequests(authorizeRequests ->authorizeRequests .requestMatchers(CorsUtils::isPreFlightRequest).permitAll() .requestMatchers(new AntPathRequestMatcher("/")).permitAll() .requestMatchers(new AntPathRequestMatcher("/login/**")).permitAll() .requestMatchers("/api/login/**").permitAll() .requestMatchers("/api/registered-client/**").permitAll() .anyRequest().authenticated() ); http.addFilterBefore(customAuthenticationProcessingFilter(), UsernamePasswordAuthenticationFilter.class); http.exceptionHandling(httpSecurityExceptionHandlingConfigurer -> httpSecurityExceptionHandlingConfigurer .authenticationEntryPoint(new CustomLoginAuthenticationEntryPoint()) .accessDeniedHandler(customAccessDeniedHandler()) ); // http.userDetailsService(customUserDetailsService); // http.formLogin(); http.csrf().disable(); return http.build(); } // @formatter:on @Bean public AccessDeniedHandler customAccessDeniedHandler() { return new CustomAccessDeniedHandler(); } @Bean public AuthenticationSuccessHandler customAuthenticationSuccessHandler() { return new CustomAuthenticationSuccessHandler(); } @Bean public AuthenticationFailureHandler customAuthenticationFailureHandler() { return new CustomAuthenticationFailureHandler(); } } Ajax 로그인 처리 필터 소스 public class CustomAuthenticationProcessingFilter extends AbstractAuthenticationProcessingFilter { private final ObjectMapper objectMapper = new ObjectMapper(); private static final AntPathRequestMatcher DEFAULT_ANT_PATH_REQUEST_MATCHER = new AntPathRequestMatcher("/api/login", HttpMethod.POST.name()); public CustomAuthenticationProcessingFilter() { super(DEFAULT_ANT_PATH_REQUEST_MATCHER); } public CustomAuthenticationProcessingFilter(AuthenticationManager authenticationManager) { super(DEFAULT_ANT_PATH_REQUEST_MATCHER, authenticationManager); } @Override public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException, IOException, ServletException { if (!request.getMethod().equals("POST")) { throw new AuthenticationServiceException("Authentication method not supported: " + request.getMethod()); } LoginRequestDto loginRequestDto = objectMapper.readValue(request.getReader(), LoginRequestDto.class); if(StringUtils.isEmpty(loginRequestDto.getLoginId())||StringUtils.isEmpty(loginRequestDto.getLoginPassword())) { throw new IllegalStateException("Username or Password is empty"); } CustomAuthenticationToken authRequest = CustomAuthenticationToken.unauthenticated(loginRequestDto, loginRequestDto.getLoginPassword()); authRequest.setDetails(this.authenticationDetailsSource.buildDetails(request)); return getAuthenticationManager().authenticate(authRequest); } } CustomAuthenticationToken 소스 public class CustomAuthenticationToken extends AbstractAuthenticationToken { private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID; private final Object principal; private Object credentials; public CustomAuthenticationToken(Object principal, Object credentials) { super(null); this.principal = principal; this.credentials = credentials; setAuthenticated(false); } public CustomAuthenticationToken(Object principal, Object credentials, Collection<? extends GrantedAuthority> authorities) { super(authorities); this.principal = principal; this.credentials = credentials; super.setAuthenticated(true); // must use super, as we override } public static CustomAuthenticationToken unauthenticated(Object principal, Object credentials) { return new CustomAuthenticationToken(principal, credentials); } public static CustomAuthenticationToken authenticated(Object principal, Object credentials, Collection<? extends GrantedAuthority> authorities) { return new CustomAuthenticationToken(principal, credentials, authorities); } @Override public Object getCredentials() { return this.credentials; } @Override public Object getPrincipal() { return this.principal; } }

  • java
  • oauth
  • spring-boot
  • spring
신석균 댓글 2 좋아요 1 조회수 1392

23.Spring MVC02 버전 만들기(Ajax, jQuery)

해결됨

스프링 프레임워크는 내 손에 [스프1탄]

SPringMVC01 폴더를 복사 후, SpringMVC02 폴더로 변경해서 강의 순서대로 실행을 했는데, Mapping 경로를 찾지 못하는 오류가 발생했습니다. 그래서 해결 방법으로 [appServlet] - [servlet-context.xml] 파일 안에 19번째 줄 기존의 파일 내용 일부분을 수정했습니다. 이렇게 해도 괜찮을까요 ? 다른 방법이 있으면 알고 싶어요 ㅠ [servlet-context.xml] - 수정 전 <resources mapping="/resources/**" location="/resources/" /> [servlet-context.xml] - 수정 <resources mapping="/assets/**" location="/resources/assets/" /> <resources mapping="/ad_assets/**" location="/resources/ad_assets/" /> ​ a

  • Spring Security
  • MVC
  • jsp
  • spring
optional94 댓글 1 좋아요 0 조회수 422

강사님의 강의노트

미해결

스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술

학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요. 1. 강의 내용과 관련된 질문을 남겨주세요. 2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요. (자주 하는 질문 링크: https://bit.ly/3fX6ygx) 3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요. (질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG) 질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요. ========================================= [질문 템플릿] 1. 강의 내용과 관련된 질문인가요? (예/아니오) 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오) 3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오) [질문 내용] 여기에 질문 내용을 남겨주세요. 강사님의 강의노트를 사이트에서 계속 찾아봤는데 찾을수가 없네요. 강의노트(소스와 개념설명)를 다운받을 수 있는 방법을 부탁드립니다.

  • spring
  • spring-boot
  • java
  • MVC
semswg 댓글 1 좋아요 0 조회수 526

강의 시작

미해결

스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술

2023 기준으로 강의를 보려 할 때 스프링 3.0 기준으로는 어떻게 강의를 확인해야할까요 ?

  • MVC
  • spring
  • mvc
  • spring-boot
  • java
도연 댓글 1 좋아요 0 조회수 296

Loading descript for 문제

미해결

스프링 프레임워크는 내 손에 [스프1탄]

안녕하세요! 나프에 이어 스프 강의까지 열심히 따라 가고 있는 학생입니다. 강의 따라 열심히 실습하고 있는데요, API 설치 이후 위와 같은 팝업이 계속 뜨고 있습니다. 혼자 해결해보려고 구글 검색해봤지만, 뭐가 문제인지 모르겠습니다. ㅠ 서버도 잘 작동되서 화면도 띄어지고 콘솔창에도 아무 문제가 나오지 않는데, 어떻게 해결하면 좋을까요?

  • Spring Security
  • mvc
  • jsp
  • spring
  • spring-security
  • MVC
지모 댓글 2 좋아요 0 조회수 711

Whitelabel Error Page 에러페이지가 뜹니다.

미해결

스프링 MVC 1편 - 백엔드 웹 개발 핵심 기술

학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요. 1. 강의 내용과 관련된 질문을 남겨주세요. 2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요. (자주 하는 질문 링크: https://bit.ly/3fX6ygx) 3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요. (질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG) 질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요. ========================================= [질문 템플릿] 1. 강의 내용과 관련된 질문인가요? (예/아니오) 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오) 3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오) [질문 내용] 새로운 프로젝트로 넘어오고나서부터 계속 에러페이지가 뜹니다. welcome페이지는 잘 뜨는거로봐서 아마 매핑이 안되는 것 같습니다. 강의자료에 있는거 그대로 복사해서 붙여넣어봤는데도 같은 화면이 출력됩니다. 뭐가 문제일까요....

  • spring
  • mvc
  • MVC
권우현 댓글 1 좋아요 0 조회수 2276

JdbcTemplate 테스트에서의 중복 회원 예외 오류가 뜨는 이유를 모르겠습니다.

미해결

스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술

학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요. 1. 강의 내용과 관련된 질문을 남겨주세요. 2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요. (자주 하는 질문 링크: https://bit.ly/3fX6ygx) 3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요. (질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG) 질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요. ========================================= [질문 템플릿] 1. 강의 내용과 관련된 질문인가요? (예) 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (비슷한 내용은 있었지만 원하는 해답을 찾지 못했습니다) 3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예) [질문 내용] 여기에 질문 내용을 남겨주세요. 차근차근 강의 예제를 따라가면서 잘 오고 있었는데 테스트 하는 부분에서 갑작스런 오류로 인해 해답을 찾던 도중 어려움을 겪어서 프로젝트 링크와 오류 사진을 남기겠습니다 https://drive.google.com/file/d/1DIAzsFD6RnTCv73h-kNpeDWUE5CsF8oC/view?usp=share_link

  • spring-boot
  • mvc
  • MVC
  • spring
  • java
김동우 댓글 2 좋아요 1 조회수 738

static 메소드와 instance 메소드의 접근?

해결됨

나도코딩의 자바 기본편 - 풀코스 (20시간)

안녕하세요 ㅎㅎ 다름이 아니라 나도코딩 자바편에서 메소드를 공부하면서 궁금증이 생겨, 이렇게 또 다시 질문을 남깁니다...ㅎ 나도코딩 자바편을 보는 것과 동시에, 제 스스로 나름 예제들도 풀면서 개념을 익히고 있는데요...ㅎ 방금 전에 제가 문자열(String)배열과 charAt()을 이용하여, 전치행렬을 만드는데 성공했습니다...ㅎ 결과도 잘 출력했구요 ㅎㅎ 이 예제를 푸는 데는 String, String[], length(), charAt()에 대한 선생님의 도움과 답변이 없었으면 풀지 못했을 건데, 선생님의 자세한 답변 덕분에 문제를 빠르게 잘 풀 수 있었습니다. 감사합니다 ㅎㅎ 아래가 제가 쓴 코드고, 출력한 결과입니다: 여기서부터가 제 질문인데요...ㅎ static 메소드(public static void main(String[] args) {...})에서 일반 메소드를 접근하려면, 에러 메시지로 'non-static variable/method cannot be referenced fromstatic context.'라고 나오는데, 이럴 경우에 에러를 없애고, 결과를 잘 출력하려면: pubilc static void main 메소드 앞에 첫 번째 방법으로 void transpose 메소드를 static void tranpose라고 바꾸거나, 아니면 2번째 방법으로 static 메소드 안에서 이렇게 Question_03 making = new Question_03(); 즉, (클래스 이름) (객체 이름) = new (클래스 이름)(); 이런 식으로 객체화를 해서 메소드를 접근해야 하나요?

  • 객체지향
  • java
  • 메소드
  • oop
  • static
댓글 1 좋아요 0 조회수 751

60강 테스트가 왜 안되는지 모르겠습니다.

미해결

스프링 프레임워크는 내 손에 [스프1탄]

import 다 맞추고 mysql도 다 맞추고 했는데 hikari에서 env가 연동이 안되어서 에러가 뜨네요 왜 그런지 이해가 안됩니다. 벌써 몇일째 60강에서 넘어가지지가 않네요 도와주세요

  • Spring Security
  • mvc
  • MVC
  • spring
  • spring-security
  • jsp
형종 댓글 2 좋아요 0 조회수 492

31강 대출기능에서 테이블 생성에 대한 질문입니다.

해결됨

자바와 스프링 부트로 생애 최초 서버 만들기, 누구나 쉽게 개발부터 배포까지! [서버 개발 올인원 패키지]

대출기능을 개발하려고 하니, 저희가 가진 두 테이블, User와 Book은 서로를 가리킬 필드가 없어서 '대출했다.'라는 정보를 표시할 수 없었습니다. 그래서 user_loan_history 테이블을 새로 만드는 내용이 강의의 주된 내용이 되는데요, 제가 궁금한건 여기서 User와 Book 테이블을 수정하여, 예를들면 User테이블에는 OneToMany로 Book의 id를 가리킬 수 있는 필드를, Book테이블에는 ManyToOne으로 User의 id를 가리킬 수 있는 필드를 추가하여 개발할 수도 있지 않나 싶어서요! 객체지향적으로 생각했을 때 User와 Book은 객체지만, '대출기록'은 객체가 아니라 객체간의 관계 같아서 테이블로 만드는 것에 거부감이 생기는 것 같습니다. 어떤 이유에서 기존의 테이블을 수정하지 않고, 새로운 테이블을 만들었는지 궁금합니다!

  • spring
  • spring-boot
  • JPA
  • java
  • aws
  • jpa
  • mysql
Dompoo 댓글 1 좋아요 2 조회수 474

IpPort 객체가 동일한 이유?

해결됨

스프링 MVC 2편 - 백엔드 웹 개발 활용 기술

안녕하세요. 강의를 듣던중 궁금한점이 생겨 질문 드립니다. 아래는 뷰 템플릿에 컨버터를 적용하는 강의에서 컨트롤러에서 사용되는 두개의 함수입니다. @GetMapping("/converter/edit") public String conveterForm(Model model) { IpPort ipPort = new IpPort("127.0.0.1", 8080); System.out.println(ipPort); Form form = new Form(ipPort); model.addAttribute("form", form); return "converter-form"; } @PostMapping("/converter/edit") public String conveterEdit(@ModelAttribute Form form, Model model) { IpPort ipPort = form.getIpPort(); model.addAttribute("ipPort", ipPort); return "converter-view"; } 위와 같은 코드에서 위의 GET mapping을 호출하면, 다음과 같은 창이 나오는데요, 저 때, th:value의 레퍼런스 정보는 'hello.typeconverter.type.IpPort@59cb0946' 입니다. 그런데, 동일한 mapping( http://localhost:8080/converter/edit ) 을 호출하면 매번 IpPort ipPort = new IpPort("127.0.0.1", 8080); 에 의해 새로운 IpPort 객체가 생성되어야한다고 생각했었는데, 계속 같은 'hello.typeconverter.type.IpPort@59cb0946' 레퍼런스가 나옵니다. 또, 위의 페이지에서 submit을 할 경우에, "ipPort=127.0.0.1:8080" 이라는 값이 서버로 전달되어서, 컨버터에 의해 변환되어 @ModelAttribute Form form 안의 IpPort로 바인딩이 되는 것인데, 해당 페이지에도 아래와 같이 동일한 레퍼런스가 나타납니다. GET localhost:8080/converter/edit 와 POST localhost:8080/converter/edit 는 독립적인 서로 다른 http 요청이라서 스프링 내부적으로 Form 객체 안의 IpPort객체를 바인딩하는 과정에서 새로운 IpPort 객체를 만들어서 바인딩 해줄 것이라고 생각했는데, 동일한 레퍼런스가 출력되었습니다. 이는 자바(JVM) 자체적으로 메모리를 관리하는 부분에 의한 영향인가요? 아니면 스프링 내부적으로 객체 레퍼런스를 재사용하는 매커니즘이 있는 건가요?

  • mvc
  • spring
  • MVC
세승 댓글 1 좋아요 0 조회수 608

스프링 빈 2개 이상 등록됨 : expected single matching bean but found 2

해결됨

스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술

안녕하세요 스프링 입문 강의 수강 중 궁금한 점이 있어 질문 남깁니다. Spring Data Jpa를 적용하면서 스프링이 JpaRepository를 가진 인터페이스의 구현체를 자동으로 생성하고 빈으로 등록한다는 것으로 이해했습니다. 따라서 기존의 Repository 클래스들의 @Repository 어노테이션과 @Service 어노테이션을 삭제 후 Configuration으로 직접 빈을 등록하도록 변경하였습니다. 자동 등록되는 어노테이션을 모두 제거하였고, Config 클래스의 memberRepository 빈 등록 부분도 주석처리 해주었으나 MemberRepositoryImpl이 빈으로 등록되어 다음과 같은 에러가 발생합니다. MemberRepositoryImpl은 어디에서 빈으로 등록되는 건가요??

  • java
  • spring-boot
  • mvc
  • spring
  • SpringBean
  • MVC
dasol199 댓글 1 좋아요 0 조회수 1401

SpringConfig에 JdbcMemberRepsoitory반환 오류

미해결

스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술

[질문 내용] SpringConfig클래스에 MemoryMemberRepsoitory 메소드에 retrun new JdbcMemberRepository();를 하고 dataSource 객체 생성 후 생성자까지 만들어주었습니다. 여기까지는 ()에 오류가 생기는데 여기에 dataSource를 넣어주면 전체오류가 생기여 옵션엔터를 눌러 해결하면 메소드 이름을 MemoryMemberRepository가 아닌 JdbcMemeberRepository로 바꿔라 합니다. 이를 변경하면 위에 MemberService도 바꿔야하며 전체코드에 이상이 생깁니다. package hello.hellospring; import hello.hellospring.repository.JdbcMemberRepository; import hello.hellospring.repository.MemoryMemberRepository; import hello.hellospring.service.MemberService; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import javax.sql.DataSource; @Configuration public class SpringConfig { DataSource dataSource; public SpringConfig(DataSource dataSource) { this.dataSource = dataSource; } @Bean public MemberService memberService(){ return new MemberService(memberRepository()); } @Bean public MemoryMemberRepository memberRepository(){ //return new MemoryMemberRepository(); return new JdbcMemberRepository(dataSource); //오류발생 } } java: incompatible types: hello.hellospring.repository.JdbcMemberRepository cannot be converted to hello.hellospring.repository.MemoryMemberRepository 이러한 오류내용이 뜹니다. 수업 소스코드와 동일하게 해봤는데 이럽니다!

  • MVC
  • java
  • mvc
  • spring-boot
  • spring
  • spring-boot
nskynet5374 댓글 1 좋아요 0 조회수 667

인기 태그

인프런 TOP Writers

주간 인기글