월 66,000원
5개월 할부 시다른 수강생들이 자주 물어보는 질문이 궁금하신가요?
- 미해결스프링과 JPA 기반 웹 애플리케이션 개발
dropdown이 기능하지 않아요 ㅠ
nav-bar에 dropdown 관련해<a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">js가 작동하지 않는 것인지, 클릭시 #만 붙고 drop-item들을 보여주질 않습니다;;선생님과 똑같이 해서 해도 기능하지 않아서라이브러리도 전부 점검해보았는데, 답을 찾기 어려워 질문 남깁니다 ㅠjustify-content-end이 부분도 css 적용이 안되고 있습니다. 제가 어느 부분을 놓쳤을까요?
- 미해결스프링과 JPA 기반 웹 애플리케이션 개발
로그인 인증 관련 질문
기선님 안녕하세요~테스트 코드로 로그인 인증 검증하는 코드 부분에서 잘 안되는 부분이 있어 문의드려요!저는 빌드 도구 gradle, spring boot 3.0.1 버전, Java 17 버전으로 개발하고 있습니다.UsernamePasswordAuthenticationToken 을 Nickname, Encryped Password를 통해 가져와서 SecurityContextHolder를 통해 token을 Set 해주는 코드가 아래와 같이 있습니다.public void login(Account account) { UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken( account.getNickname(), account.getPassword(), List.of(new SimpleGrantedAuthority("ROLE_USER"))); SecurityContextHolder.getContext().setAuthentication(token); } SecurityMockMvcResultMatchers의 authenticated로 테스트 코드 계정 인증 시키는 부분에서 "Authentication should not be null" 이슈가 발생하네요.디버깅 시도 해보면, mockMvc 마지막 검증(authenticated) 쪽에서는 분명 test라는 nickname도 갖고 있지만.. authenticated 호출되는 시점에 request Session을 가져오면 null이 나와버리네요 ㅠㅠ. 사용 중인 SecurityMockMvcResultMatchers 자체 버전은 다르긴 하지만.. 코드는 완전 동일한데 이런 오류가 발생하네요 ㅠ 혹시 해결을 위해 해볼 만한 시도가 있을까요~?void checkEmailToken_with_correct_input() throws Exception { Account account = Account.builder() .email("test@email.com") .password("12345678") .nickname("test") .build(); Account newAccount = accountRepository.save(account); newAccount.generateEmailCheckToken(); mockMvc.perform(get("/check-email-token") .param("token", newAccount.getEmailCheckToken()) .param("email", newAccount.getEmail())) .andExpect(status().isOk()) .andExpect(model().attributeDoesNotExist("error")) .andExpect(model().attributeExists("nickname")) .andExpect(model().attributeExists("numberOfUser")) .andExpect(view().name("account/checked-email")) .andExpect(authenticated()); }
- 해결됨스프링과 JPA 기반 웹 애플리케이션 개발
Windows 환경에서 프로필 이미지 변경 Jdenticon 안보이는 현상 문의
안녕하세요.Windows 환경에서 프로필 이미지 변경 화면 접속 시, 아래와 같이 Jdenticon이 안보이는 현상이 발견되네요.IDE를 통해 로컬에서 실행하여 확인할때뿐만 아니라 프로젝트를 Dockerizing한 후, 외부 서버에 컨테이너 형태로 띄운 상태에서 접속하여 동작 확인을 해도 동일한 현상이 나옵니다. 이와 반대로, Mac OS 환경에서는 모두 정상적으로 나옵니다.위 현상과 관련하여 뭔가 Dependency가 있는 요소가 있는걸까요?? 브라우저 캐시 삭제를 해봤는데도 마찬가지네요. 구글링해봐도 관련 내용이 잘 나오지도 않고요. 어떻게 해결할 수 있을지 문의드립니다.
- 미해결스프링과 JPA 기반 웹 애플리케이션 개발
DevTools 관련 질문
안녕하세요.Thymeleaf를 이용한 html 파일 수정 후 재시작하지 않고 반영된 내용을 곧바로 확인하기 위해 아래와 같이 구성했습니다.resources/application.yml spring: profiles: active: local devtools: restart: enabled: false thymeleaf: cache: falseIntellij 설정Run/Debug Configurations > Spring Boot > (구동중인 App)On 'Update' action/On frame deactivation > Update class and resources로 설정.Settings > Build, Execution, Deployment > Compiler에 "Build project automatically" 선택.Settings > Advanced Settings > "Allow auto-make to start even if developed application is currently running" 선택.위와 같이 구성해놓고 브라우저에서 화면을 띄우면 아래와 같이 간헐적으로 TemplateInputException이 나옵니다. resources/ 하위에 있는 앞단 코드를 수정한 후, 수정한 내역을 확인할 때도 간헐적으로 나옵니다.ERROR 9104 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: Error resolving template [index], template might not exist or might not be accessible by any of the configured Template Resolvers] with root cause org.thymeleaf.exceptions.TemplateInputException: Error resolving template [index], template might not exist or might not be accessible by any of the configured Template Resolvers at org.thymeleaf.engine.TemplateManager.resolveTemplate(TemplateManager.java:869) ~[thymeleaf-3.0.15.RELEASE.jar:3.0.15.RELEASE] at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:607) ~[thymeleaf-3.0.15.RELEASE.jar:3.0.15.RELEASE]그리고 위에 기재한 설정에서 On frame deactivation 설정을 아예 지워버리면, 서버를 내렸다 올려야만 변경된 내용 확인이 가능한 상황입니다.어떠한 문제가 있는건지 전혀 감이 안오네요.어떠한 부분을 추가로 확인해봐야하나요??확인 후 알려주시면 감사하겠습니다.
- 미해결스프링과 JPA 기반 웹 애플리케이션 개발
sign-up 폼이 깨지는 현상이 있습니다.
안녕하세요!완성된 코드 sign-up.html 코드를 그대로 사용하였는데 아래 사진 처럼 깨지고 있습니다..그 외에도 다른 의존적인 html, js 파일을 들고와도 깨지는 현상이 나타나는것 같습니다.추가로 email 인증 구현을 해보았는데 email 꺼내오는 부분에서 npe가 나서 폼 자체에서 값을 Account 객체 필드에 직렬화하지 못하는거 같은데.. (email, nickname) 이 부분에 대해서 조언을 구하고 싶습니다. 감사합니다. :)
- 미해결스프링과 JPA 기반 웹 애플리케이션 개발
태그 추가하는 컨트롤러에서 title이 null로 뜹니다.
디버깅도 해보았는데id는 insert가 되는데 title이 null로 잡힙니다. 코드도 누락된게 없는 것 같은데혹시 이유가 뭘까요...?제이쿼리가 잘못된걸까요???? //mysql에서 title에 직접 주입해주면view가 제대로 반영이 되는데반대로 view에서 입력하면 db에 들어오지 않습니다.
- 미해결스프링과 JPA 기반 웹 애플리케이션 개발
스터디 소개 수정 실패 테스트에서 @NotBlank 적용 문제
안녕하세요.스터디 소개 수정 실패 테스트하다가 발견한 궁금증 문의드립니다.study -> lesson 으로만 변경하고 다 동일합니다.스터디 짧은 소개에 "" 문자를 넣으면 @NotBlank 로 error 가 발생하여 200 상태코드가 떨어져야하지만 에러가 걸리지 않고 redirect 를 하게 됩니다. @NotBlank 로 특정 문자가 하나라도 있어야 하지만 없어도 통과되는 문제가 궁금합니다. @NotBlank(min = 1, max = 50) 으로 바꾸고 하니 error 로 잡히는데 그렇지 않을 경우에 왜 통과 될까요?ㅠㅠ
- 미해결스프링과 JPA 기반 웹 애플리케이션 개발
M1 mac 에서 gradle로 빌드하시려는 분들께 공유 하고싶어 글을 남겨요!
Requirementsstatic/node_module로 package.json에 선언된 의존성을 다운로드 받아야한다gradle build 시 package.json에 선언된 의존성을 확인하고 다시 다운로드 받아야 한다.뭔가 간단하게 끝내고 싶다 !!!Actionhttps://github.com/node-gradle/gradle-node-plugin/blob/master/docs/usage.md다양한 관련 플러그인 들이 있지만, 위의 플러그인을 설치 했습니다.2번의 요구사항은 gradle의 증분 컴파일(?)이 해주는 것 같습니다. (정확하지 않음 추측이에요)3번은 관련 자료를 찾던 도중 processResources 를 발견했고, Copies production resources into the production resources directory. 라고 설명 되어 있습니다.(공식 홈페이지)따라서, npm install 시 node_module 파일을 static 이하로 떨어 뜨리면 되겠구나!그리고 processResources를 "npm install 동작을하는 " Task를 의존하게 하면 되겠구나!-- 주석이 많아 가독성이 떨어지지만, 한번 읽어보시면 더 도움이 될거라 생각해서 위의 깃헙에 있는 주석 그대로 복사 붙여넣기 합니다. 수정한 부분은 nodeProjectDir 부분과processResources.dependsOn 부분 입니다.추가로 package.json 도 아래분이 잘 정리 해주셔서 함께 복사 붙여넣기 합니다.(고맙습니다!!)-인텔리제이 빌드시(gradle로 설정안했을 경우 동작안해요!)-gradle 탭 누르셔서 npm Task 들어오는지 확인해주세요!{ "name": "static", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC", "dependencies": { "@yaireo/tagify": "^3.5.1", "bootstrap": "^4.4.1", "cropper": "^4.1.0", "font-awesome": "^4.7.0", "jdenticon": "^2.2.0", "jquery": "^3.4.1", "jquery-cropper": "^1.0.1", "mark.js": "^8.11.1", "moment": "^2.24.0", "summernote": "^0.8.16" } }plugins { id "com.github.node-gradle.node" version "3.5.0" id 'org.springframework.boot' version '2.7.5' id 'io.spring.dependency-management' version '1.0.15.RELEASE' id 'java' } group = 'me.studyOlle' version = '0.0.1-SNAPSHOT' sourceCompatibility = '17' configurations { compileOnly { extendsFrom annotationProcessor } } repositories { mavenCentral() } node { // Whether to download and install a specific Node.js version or not // If false, it will use the globally installed Node.js // If true, it will download node using above parameters // Note that npm is bundled with Node.js download = true // Version of node to download and install (only used if download is true) // It will be unpacked in the workDir version = "16.14.0" // Version of npm to use // If specified, installs it in the npmWorkDir // If empty, the plugin will use the npm command bundled with Node.js npmVersion = "" // Version of Yarn to use // Any Yarn task first installs Yarn in the yarnWorkDir // It uses the specified version if defined and the latest version otherwise (by default) yarnVersion = "" // Base URL for fetching node distributions // Only used if download is true // Change it if you want to use a mirror // Or set to null if you want to add the repository on your own. distBaseUrl = "https://nodejs.org/dist" // Specifies whether it is acceptable to communicate with the Node.js repository over an insecure HTTP connection. // Only used if download is true // Change it to true if you use a mirror that uses HTTP rather than HTTPS // Or set to null if you want to use Gradle's default behaviour. allowInsecureProtocol = null // The npm command executed by the npmInstall task // By default it is install but it can be changed to ci npmInstallCommand = "install" // The directory where Node.js is unpacked (when download is true) workDir = file("${project.projectDir}/.gradle/nodejs") // The directory where npm is installed (when a specific version is defined) npmWorkDir = file("${project.projectDir}/.gradle/npm") // The directory where yarn is installed (when a Yarn task is used) yarnWorkDir = file("${project.projectDir}/.gradle/yarn") // The Node.js project directory location // This is where the package.json file and node_modules directory are located // By default it is at the root of the current project nodeProjectDir = file("${project.projectDir}/src/main/resources/static") // Whether the plugin automatically should add the proxy configuration to npm and yarn commands // according the proxy configuration defined for Gradle // Disable this option if you want to configure the proxy for npm or yarn on your own // (in the .npmrc file for instance) nodeProxySettings = ProxySettings.SMART } dependencies { // View Template Engine implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' // Security implementation 'org.springframework.boot:spring-boot-starter-security' implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity5' //Web implementation 'org.springframework.boot:spring-boot-starter-mail' implementation 'org.springframework.boot:spring-boot-starter-web' implementation group: 'org.springframework.boot', name: 'spring-boot-starter-validation', version: '2.7.5' //Persistence implementation 'org.springframework.boot:spring-boot-starter-data-jpa' runtimeOnly 'com.h2database:h2' runtimeOnly 'com.mysql:mysql-connector-j' // LomBok compileOnly 'org.projectlombok:lombok' annotationProcessor 'org.projectlombok:lombok' // Dev developmentOnly 'org.springframework.boot:spring-boot-devtools' annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor' //Test Implementation testImplementation 'org.springframework.boot:spring-boot-starter-test' testImplementation 'org.springframework.security:spring-security-test' } tasks.named('test') { useJUnitPlatform() } processResources.dependsOn('npmInstall')
- 미해결스프링과 JPA 기반 웹 애플리케이션 개발
/study/path 검증실패시 리다이렉트 처리에 대한 궁금증
강의와 같은 뷰 템플릿에서 보내는 post요청입니다. 기존 Post /study/path 의 경우 @PostMapping("/study/path") public String updateStudyPath(@CurrentUser Account account, @PathVariable String path, @RequestParam String newPath, Model model, RedirectAttributes attributes) { Study study = studyService.getStudyToUpdateStatus(account, path); if (!studyService.isValidPath(newPath)) { model.addAttribute(account); model.addAttribute(study); model.addAttribute("studyPathError", "해당 스터디 경로는 사용할 수 없습니다. 다른 값을 입력하세요."); return "study/settings/study"; } studyService.updateStudyPath(study, newPath); attributes.addFlashAttribute("message", "스터디 경로를 수정했습니다"); return "redirect:/study/" + getPath(newPath) + "/settings/study"; } 같은 이름의 경로 요청시, 변경이 불가한 메세지를 나타내고, 페이지는 /study//settings/study를 나타내지만 주소창은 post요청의 영향으로 추가적으로 path가 더 붙는 것을 확인했습니다.이상태에서 의도적일순 있으나 URL자체로 요청을 보내는 경우 /path가 붙은 Get요청을 하게되면 아래와 같은 화면을 보게 됩니다.따라서 해당 문제점을 해결하기 위해 아래 처럼 변경하였습니다. @PostMapping("/study/path") public String updateStudyPath(@CurrentUser Account account, @PathVariable String path, @RequestParam String newPath, Model model, RedirectAttributes attributes) { Study study = studyService.getStudyToUpdateStatus(account, path); if (!studyService.isValidPath(newPath)) { model.addAttribute(account); model.addAttribute(study); attributes.addFlashAttribute("studyPathError", "해당 스터디 경로는 사용할 수 없습니다. 다른 값을 입력하세요."); return "redirect:/study/" + getPath(newPath) + "/settings/study"; } studyService.updateStudyPath(study, newPath); attributes.addFlashAttribute("message", "스터디 경로를 수정했습니다"); return "redirect:/study/" + getPath(newPath) + "/settings/study"; }기존의 model에 추가한 attribute는 리다이렉트 요청시 없어지기 때문에 메세지 출력에 필요한 studyPathError는 FlashAttirbute로 변경해주었습니다. 잘못된 경로변경 요청시 결과입니다.redirect 결과로 /path가 붙어 나오지 않음 이 경험으로 위와 같은 상황에서는 Post요청으로 Redirect가 더 안전(?)하다고 생각했습니다.하지만 매번 Redirect시킬수는 없을 것 같은데 존재하지 않는 API의 경우에 기준 URL로 리다이렉트 시키나요?예를 들자면/study/path/settings/study/path 의 경우에 /study/path/settings처럼예상되는 url들의 경우 getMapping으로 다중처리하는 걸까요?
- 미해결스프링과 JPA 기반 웹 애플리케이션 개발
AccountController.sendEmailLoginLink 문의
안녕하세요 강사님(강사님 강좌는 3번째 보고 있습니다.)AccountController.sendEmailLoginLink 에서model.addAttribute("error", "유효한 이메일 주소가 아닙니다."); return "account/email-login";대신 아래를 attributes.addFlashAttribute("error", "유효한..); return "redirect:/email-login";사용해야 하는 것 아닌지요? @PostMapping("/email-login") public String sendEmailLoginLink(String email, Model model, RedirectAttributes attributes) { Account account = accountRepository.findByEmail(email); if (account == null) { model.addAttribute("error", "유효한 이메일 주소가 아닙니다."); return "account/email-login"; } if (!account.canSendConfirmEmail()) { model.addAttribute("error", "이메일 로그인은 1시간 뒤에 사용할 수 있습니다."); return "account/email-login"; } accountService.sendLoginLink(account); attributes.addFlashAttribute("message", "이메일 인증 메일을 발송했습니다."); return "redirect:/email-login"; }
- 미해결스프링과 JPA 기반 웹 애플리케이션 개발
안녕하세요 entity generateEmailCheckToken 생성자 관련 질문드립니다.
dto 에generateEmailCheckToken 생성자를만들어서처리해주어도 문제없을까요?현재 save 처리도Dto 클래스에서dto를 entity화 해서 처리해준 상황입니다.completeSignUp 등등 생성자를dto에서 만들고 싶은데문제가 있을까요~?
- 미해결스프링과 JPA 기반 웹 애플리케이션 개발
@Transactional(readOnly=true)에서 save
AccountRepository 클래스 위에 @Transactional(readOnly=true)를 해서 성능향상을 볼수 있다고 하셧는데, save() 쓰기 작업도 호출하시더라구요이럴경우 에러는 안나는걸까요?메소드 명을 보고 알아서 쓰기인지 읽기인지 판단해서 읽기의 경우에만 저 애너테이션이 적용되는걸까요?
- 미해결스프링과 JPA 기반 웹 애플리케이션 개발
Test 코드에 Autowired가 안됩니다.
권장하지 않는것 같은데 에러 때문에 코드가 깨지네요 ㅠㅠ
- 미해결스프링과 JPA 기반 웹 애플리케이션 개발
실행관련 문의드립니다.
백기선님 안녕하세요.다름이 아니라 프로젝트 인텔리제이로 받고 clean -> compile 진행시 아래와 같은 에러가 떠서 확인 해 보니antlr 부분에서 에러가 나는데 .. 혹시 제가 놓친 부분이 있을까요?
- 미해결스프링과 JPA 기반 웹 애플리케이션 개발
@AuthenticationPrincipal를 통해 인증 객체로 가져온 Account 업데이트 시 merge 가 아닌 set 업데이트 문제점
안녕하세요. 강의 진행 중에 궁금한 점이 생겨 문의드립니다.강의에서는 Account 객체 업데이트가 필요할 시 AccountRepository의 save()를 통하여merge 방식으로 업데이트를 진행하는데 저는 merge 방식으로 하지 않고 Account를 findById() 로 조회하여 영속성 상태로 만든 후에 set 프로퍼티로 업데이트를 진행하였습니다. @Transactional public void updateProfile(Account account, Profile profile) { account = accountRepository.findById(account.getId()) .orElseThrow(IllegalArgumentException::new); modelmapper.map(profile, account); //accountRepository.save(account); }가령 프로필 업데이트 시 이렇게 하면 account 가 정상적으로 데이터베이스에 반영되나@AuthenticationPrincipal에 담긴 인증 객체는 초기 상태인 account 로써 동기화가 되지 않습니다.따라서, 업데이트 후 프로필 폼으로 이동 시에 업데이트가 안된 화면이 조회되어 일일이 폼 조회 시에도 account를 재조회하여 화면 폼에 뿌려주는 방식으로 변경하였으나 혹여 set 프로퍼티로 업데이트 할 때 @AuthenticationPrincipal에 담긴 인증객체도 같이 동기화 되도록 할 수 있는 방법이 있을까 싶어 문의드립니다.구글링으로 알아보려하였으나 원하는 정보를 찾지 못해 질문드립니다. 감사합니다.
- 미해결스프링과 JPA 기반 웹 애플리케이션 개발
@Length, @Size
안녕하세요, 강사님!제가 알기로는 @Length가 Hibernate에 종속적이어서 @Size가 더 가볍고 기능은 둘 다 동일하게 길이에 대한 유효성 검사를 하는 것으로 알고 있는데 혹시 @Length를 사용하는 추가적인 이유가 존재할까요..?
- 미해결스프링과 JPA 기반 웹 애플리케이션 개발
leftjoin에 관한 질문입니다.
처음에 N+1을 해결하시기전에 tag만 leftjoin으로 보여주시고 중복되는 row를 보여주시는 부분에서 질문이있습니다. 해당 sql문이 동작하는 방식이 아래인것같은데where문이 먼저 study중 jpa가 들어간 study만 조회해온다.후에 해당 study 에 연관된 애들만 fetch join해서 가져온다.궁금한것은 왜 join먼저 되고 where문이 걸러주지 방식으로 동작하지 않는건가요..? 원래 이 방식이 sql 문에 join 과 where을 같이 썼을때 동작하는 방식이 아닌가요..?
- 미해결스프링과 JPA 기반 웹 애플리케이션 개발
첨부파일 문의
강의자료 첨부파일 다운로드 시 studyolle2.zip라는 36메가 정도의 압축파일이 받아집니다. 강의에서는 75메가 정도라고 하셨고 실제 다운로드 후 생성된 파일명을 보면 studyolle.zip인데요..첨부파일이 바뀐건가요?
- 미해결스프링과 JPA 기반 웹 애플리케이션 개발
실습진행중에 질문 드립니다.!
먼저 좋은 강의에 너무 감사 말씀드립니다. 아래에 getMemberId()는 entity에 식별자 값입니다. 이처럼 엔티티 식별자 값으로 구현하는것이nickname 혹은 email로 구현하는것과 비교해서 보안같은 것에 문제가 있을까 질문드립니다.개인적으로 고민해봤을때 URL에 파라미터로 nickname이나 Email보다는 식별자가 좀 더 안전할거 같기도하고또 이 식별자값도 UUID같은걸로 감추는건 어떨지 질문드립니다 감사합니다. @Getterpublic class MemberAccount extends User { private Member member; public MemberAccount(Member member) { super(member.getMemberId().toString(), member.getPassword(), List.of(new SimpleGrantedAuthority("ROLE_USER"))); this.member = member; }}
- 미해결스프링과 JPA 기반 웹 애플리케이션 개발
태그를 입력할때 insertBefore 에러
저런 에러가 발생하고, 하단에 단어가 추가되지 않습니다. 원인이 무엇인지 모르겠습니다.. (tags.html의 구성은 강사님과 똑같이 하였습니다.) 단어를 추가하려고 할때마다 박스 아래에 단어는 추가되지않고, 같은 에러가 계속 추가됩니다.