Java/Spring Boot (11) 썸네일형 리스트형 [SpringBoot] 이클립스에서 메인 클레스를 찾을 수 없음 maven으로 java spring 프로젝트를 하던 중 이클립스에서 아래와 같은 오류가 발생했다.Error: Could not find or load main class프로젝트 clean 해보고 refrash해보고 다시 시작해보고 classpath를 바꿔보고 자바 버전을 바꿔보고 별 수를 다 썼지만 해결되지 않았다.해당 프로젝트 경로에 cmd로 접속하여 mvn compile입력 후 다시 실행하면 문제없이 실행된다.해당 프로젝트 마우스 우클릭 > Mavne > update 를 클릭하면 문제없이 실행된다. [SpringBoot] google oauth2 관련 설정 I. 클라이언트 ID 설정승인된 리다이렉션 URIhttp://localhost:8080/login/oauth2/code/google스프링부트에서는 반드시 이 주소로 적어야 한다.종종 http://localhost:8080/authorize/oauth2/code/google로 리다이렉션 되는 경우가 있어서 이 주소도 추가했다.II. scope 설정구글 oauth2 용 설정파일 생성resources/application-oauth.propertiesspring.security.oauth2.client.registration.google.client-id=829901496470-54rufes6a8ur76os805ptftkgh2fb816.apps.googleusercontent.comspring.security.. [SpringBoot] Could not find acceptable representation vscode에서 lombok을 임포트하고 getter setter 어노테이션을 썼는데도 작동하지 않아서 생기는 문제였다.vscode에서는 빌드파일에 의존성을 추가해주는 것과 별도로 따로 lombok extension을 설치해야한다.설치하고나서 다시 돌려보면 문제없이 작동한다. [SpringBoot] 엔드포인트 권한 에러 스프링 엔드포인트 접속 시, 아래와 같은 에러 페이지가 뜨는 경우가 있다. Whitelabel Error PageThis application has no explicit mapping for /error, so you are seeing this as a fallback.Tue Mar 09 02:22:08 KST 2021There was an unexpected error (type=Unauthorized, status=401).Full authentication is required to access this resource. 나는 /env로 접속시 발생했다.resources/application.properties 파일에management.security.enabled=false를 추가하면 문제없이.. [SpringBoot] Spring Seurity 적용 후 회원가입 안됨 Spring Seurity 적용 후 잘 되던 회원가입 기능이 동작하지 않는 문제가 발생했다.csrf 무시 설정을 적용하지 않아서였다. 해결법SecurityConfig 파일에 csrf 공격 방지 기능을 사용하고 싶지 않은 경로를 설정하기http. authorizeRequests() .... .and() .csrf().ignoringAntMatchers("/signup") .and() ...//아예 csrf 설정을 끌 수도 있다. csrf().disable()jsp 파일의 폼 태그 마지막에 다음과 같이 추가한다 ... 1번 방법의 경우 보안이 취약해지므로 지양해야한다. [SpringBoot] 서버 시작 시 에러 spring-boot 프로젝트를 생성하고 mvnw spring-boot:run명령어를 입력 하자마자 에러가 났다. Description:Web server failed to start. Port 8080 was already in use.Action:Identify and stop the process that's listening on port 8080 or configure this application to listen on another port.[INFO] ------------------------------------------------------------------------[INFO] BUILD FAILURE[INFO] ------------------------------------.. [SpringBoot] Spring Seurity 정리 Spring Security Role 여러개 설정하기이 프로젝트에 Role 3개 존재한다.사원(STAFF), 매니저(MANAGER), 사장님(OWNER).STAFF정석으로 권한 계층 설정하는 방법도 있던데 너무 어려워서 다음에 해봐야겠다..authorizeHttpRequests() .antMatchers("/error/**", "/css/**", "/images/**", "/js/**").permitAll() .antMatchers("/dashboard", "/request/**", "/mypage").hasAnyRole("ROLE_STAFF", "ROLE_MANAGER", "ROLE_OWNER") .antMatchers( .. [SpringBoot] input 태그의 date 타입을 자바 Date 객체로 파싱하기 form에 다음과 같이 input 태그를 date타입으로 설정하고 제출하면 Date 타입으로 자동으로 변환되지 않는다.400 bad request 에러를 얻게 된다.This application has no explicit mapping for /error, so you are seeing this as a fallback.There was an unexpected error (type=Bad Request, status=400).Validation failed for object='formDto'. Error count: 1org.springframework.web.method.annotation.ModelAttributeMethodProcessor$1: org.springframework.valida.. [Spring Boot] gmail 전송하기 구글 계정 > 보안에서 2단계인증을 활성화하고 앱 비밀번호를 발급 받아야한다.앱은 지메일, 플랫폼은 아무거나 선택하면 된다.application.properties### mail service ### spring.mail.host=smtp.gmail.comspring.mail.port=587spring.mail.username='sender email'spring.mail.password='app passowrd'spring.mail.properties.mail.smtp.auth=truespring.mail.properties.mail.smtp.starttls.enable=trueGmailService.java...import org.springframework.mail.SimpleMailMessage;.. [SpringBoot] CORS 대응 WebConfig 파일에 추가한다. /** * CORS 대응 */@Overridepublic void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") //.allowedOrigins("http://localhost:8080") .exposedHeaders("*") .allowedMethods("GET", "POST", "PUT", "DELETE");} 이전 1 2 다음