<!-- security -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<!-- redis 세션저장 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-redis</artifactId>
</dependency>
<!-- h2 db (개발용)-->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope> <!-- *** 배포시에는 삭제 -->
</dependency>
<!-- h2 또는 oracle session -->
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-jdbc</artifactId>
</dependency>
<!-- oracle (서비스용)-->
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
</dependency>
<!-- mybatis -->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.2.0</version>
</dependency>
<!-- thymeleaf -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<!-- tomcat (개발용 웹 서버) -->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<!-- web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- devtools -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<!-- lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<!-- spring boot 자동으로 생성되는 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<!-- spring boot 테스트 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
# 개발용 포트번호
server.port=9090
# 프로젝트, 배포하는 파일명
server.servlet.context-path=/ROOT
# 소스코드 자동감지 후 재시작
spring.devtools.livereload.enabled=true
# view에 해당하는 html의 위치
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
# h2 db (개발용 DB)
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.url=jdbc:h2:file:D:/java-workspace/boot_20220406/db01;Mode=Oracle;
# db01은 db파일 이름
spring.datasource.username=sa
spring.datasource.password=
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
# oracle (서비스용 DB)
# spring.datasource.driver-class-name=oracle.jdbc.OracleDriver
# spring.datasource.url=jdbc:oracle:thin:@1.234.5.158:11521/xe
# spring.datasource.username=ds200
# spring.datasource.password=pw200
# h2 또는 oracle 세션 사용
# server.servlet.session.timeout=3600
# spring.session.store-type=jdbc
# spring.session.jdbc.initialize-schema=always
# db컨넥션 유지
spring.datasource.hikari.connection-test-query=SELECT 1 FROM DUAL
spring.datasource.hikari.connection-timeout=600000
spring.datasource.hikari.maximum-pool-size=500
spring.datasource.hikari.max-lifetime=1800000
spring.datasource.hikari.minimum-idle=20
spring.datasource.hikari.validation-timeout=3000
spring.datasource.hikari.idle-timeout=60000
# redis 세션 사용
spring.redis.host=1.234.5.158
spring.redis.port=16379
spring.redis.password=ds606
# mongodb에 사용했던 번호 ex) 200 => 0, 214 => 14, 219 => 19
spring.redis.database=0
server.servlet.session.timeout=3600
spring.session.store-type=redis
spring.session.redis.flush-mode=immediate
이미지나, 페이지네이션 같은 건 나중에 되면 찾기 힘들다.
global.properties에서 만들고 끌어다 쓴다
board.page.count=10
default.image=classpath:/static/images/default.png
package com.example.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
@Controller
public class HomeController {
@GetMapping(value = { "/", "/home", "/main" })
public String getHome() {
return "home";
// /를 붙여도 되고 안붙여도 됨 근데 안붙이는 게 좋은듯
}
}
package com.example.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.
EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.
WebSecurityConfigurerAdapter;
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
// 로그인 화면 뜨는 거 막기
// super.configure(http);
// h2-console 보안 제거하기 배포 시 주석잡기
http.csrf().ignoringAntMatchers("/h2-console/**");
http.headers().frameOptions().sameOrigin();
}
}