https://github.com/aldwindelgado/spring-boot-oauth2-server 프로젝트를 fork함.
...
...
> docker-compse -f docker-compose-mysql.yml up -d
> docker ps
> docker exec -it spring-boot-oauth2-server_mysql_1 bash
> mvn clean package spring-boot:run
아래와 같이 서버 기동시 사용자 정보가 추가됩니다.
package com.github.oauth2.server;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import com.github.oauth2.server.UserRepository;
import com.github.oauth2.server.User;
@Service
public class UserInit {
@Autowired
private PasswordEncoder passwordEncoder;
@Autowired
private UserRepository userDao;
@PostConstruct
public void printEndocedPassword() {
User alex = user(1L, "Alex123", "password", 3456, 33);
User tom = user(2L, "Tom234", "password", 7823, 23);
User adam = user(3L, "Adam", "password", 4234, 45);
User hazin = user(4L, "hazin", "woo", 52, 9);
userDao.save(alex);
userDao.save(tom);
userDao.save(adam);
userDao.save(hazin);
}
private User user(long id, String username, String password, long salary, int age) {
User user = new User();
user.setId(id);
user.setUsername(username);
user.setPassword(passwordEncoder.encode(password));
user.setSalary(salary);
user.setAge(age);
return user;
}
}
https://github.com/woozoo73/spring-boot-oauth2-client
> mvn clean package spring-boot:run