Web/Spring

· Web/Spring
내가 설정해둔 spring의 암호화 방법은 bCrypt이다. //MvcConfig @Bean(name = "bCryptPasswordEncoder") public BCryptPasswordEncoder passwordEncoder() { return new BCryptPasswordEncoder(); } 초기 admin 계정을 넣을 때 비밀번호를 어떻게 찾을까? https://www.devglan.com/online-tools/bcrypt-hash-generator 위의 사이트에서 text를 넣고 rounds를 선택해 Hash를 누르면 저절로 암호화된다. 이 암호문을 data.sql에 알맞은 위치에 넣고 실행시키면 admin 계정 비밀번호가 잘 저장되어 있을 것이다. 더 자세한 내용은 https://ju..
· Web/Spring
spring을 처음 실행시킬 때 초기 데이터를 넣어주기 위함이다. application.yml 또는 application-local.yml spring: datasource: initialization-mode: always 처음에 이 상태로 실행시킨다. data.sql 위와 같이 data.sql 파일을 만들고 초기 데이터에 대한 SQL문을 넣는다. 위의 두개 설정을 마치고 실행시키면 DB에 초기값이 들어간다. 이후에 yml파일의 initialization-mode의 속성을 never로 바꾸어준다!
· Web/Spring
Intelli J에서 실행은 되지만 크롬 브라우저에서 들어가려고 하니.. 오류가 뜬다! 해결방법! 주소를 https:// 에서 http://로 바꿔서 접속한다 ❗ 너무 간단해서 오히려 화가난다.. ❗ ❗ http와 https 사용법도 나중에 정리해야지.. ❗
· Web/Spring
Role 사용을 해보자 내 프로젝트의 경우 ADD버튼이 admin으로 로그인했을 때만 나타나야 한다. Role @Getter @AllArgsConstructor public enum Role { ROLE_ADMIN("관리자", RoleBase.ADMINISTRATOR), ROLE_USER("사용자", RoleBase.USER); private String text; private RoleBase roleBase; public static List findByRoleBase(RoleBase roleBase) { return Arrays.stream(Role.values()).filter(p -> p.getRoleBase().equals(roleBase)) .collect(Collectors.toList()..
· Web/Spring
화면 구성(resources/templates/auth) register.html 회원가입 양식 이름 * 중복확인 r 비밀번호 가입취소 회원가입 간단하게 아이디, 비밀번호, 사용자 이름 폼을 사용, 아이디 중복확인 기능도 존재 AuthController @Controller @RequiredArgsConstructor @RequestMapping("/auth") public class AuthController { @NonNull private final UserService userService; @NonNull private final SmartValidator validator; @RequestMapping("/register") public String registerSelect() { retur..
· Web/Spring
login을 위한 setting pom.xml org.springframework.boot spring-boot-starter-security org.thymeleaf.extras thymeleaf-extras-springsecurity5 domain-User @Getter @Setter @Entity @Table(name = "user", indexes = {@Index(columnList = "username"), @Index(columnList = "name"), @Index(columnList = "role"), @Index(columnList = "enabled"), @Index(columnList = "removed")}) @NoArgsConstructor @EqualsAndHashCode(o..
yj_oo_
'Web/Spring' 카테고리의 글 목록