기존 Controller @RequiredArgsConstructor @Controller public class IndexController { private final GamesService gamesService; private final HttpSession httpSession; @GetMapping("/") public String index(Model model){ model.addAttribute("games", gamesService.findAllPaging(0,9)); SessionUser user = (SessionUser) httpSession.getAttribute("user") if (user != null) { model.addAttribute("userName",user.ge..
1. Security 설정 스프링 시큐리티를 사용하는데 쓸 기능들을 명시해준다 @RequiredArgsConstructor // 스프링 시큐리티 설정 활성화 @EnableWebSecurity public class SecurityConfig extends WebSecurityConfigurerAdapter { private final CustomOAuth2UserService customOAuth2UserService; protected void configure(HttpSecurity http) throws Exception { http .csrf().disable() .headers().frameOptions().disable().disable() .authorizeRequests() //URL 별 ..
TestCode @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT) @Transactional public class GamesApiControllerTest extends TestCase { @Autowired private TestRestTemplate restTemplate; @LocalServerPort private int port; @Test public void testGamesReResponse() { Integer request = 1; String url = "http://localhost:"+port+"/api/appendGames"; //when Re..
문제점 너무 많은 태그들이 나와서 태그 개수를 제한해야함. 해결책 public GameLimitTagListResponseDto(Game entity) { this.gameId = entity.getGameId(); this.gameName = entity.getGameName(); this.gameInfo = entity.getGameInfo(); this.launchDate = entity.getLaunchDate(); this.evaluation = entity.getEvaluation(); this.imgUrl = entity.getImgUrl(); this.videoUrl = entity.getVideoUrl(); this.devCompany = entity.getDevCompany(); thi..
Error log java.lang.IllegalStateException: Cannot call sendError() after the response has been committed Game @Getter @Entity @Table(name = "GAMES") @NoArgsConstructor public class Game { // 게임 아이디(PK) @Id @Column(name = "GAME_ID") private Long gameId; // 게임 이름 @Column(name = "GAME_NAME") private String gameName; // 게임 정보 @Column(name = "GAME_INFO") private String gameInfo; ... @OneToMany(mapped..
1. AOP란 어떤 서비스나 메서드가 실행되기전에 공통적으로 들어 가야할 이벤트, 메서드 등이 필요 할때 사전에 정의해둔 클래스를 작동하고 나서 실제 서비스가 작동하게 하는 것. 2. AOP의 장점 불필요한 비지니스 로직이 줄어서 좀 더 직관적인 비지니스 로직을 짤 수 있음. 3. 사용 예시 @Aspect @Component public class TimeTraceAop { @Around("execution(* hello.hellospring..*(..))") public Object execute(ProceedingJoinPoint joinPoint) throws Throwable { long start = System.currentTimeMillis(); System.out.println("START..