H2
15822 ワード
H 2とは?
H 2はJavaベースのオープンソースRDBMSである.サーバモード、Embeddedモード(InmemoryDB)をサポートし、ディスクベースのテーブルを作成できます.ブラウザベースのコンソールモードを提供し、単独でインストールする必要がなく、速度が非常に速く、容量が2 MB未満です.
Spring boot+H 2データベースのローカル環境の適用


Using the H2 Database Console in Spring Boot with Spring Security




「




💡 Spring Security設定を検索する場合は、Spring Profileのローカル設定と他の設定に分ける方法を参照して、プロジェクトが同じように適用されることを確認してください.
private final Environment env;
public SecurityConfig(JwtTokenProvider jwtTokenProvider, Environment env) {
this.jwtTokenProvider = jwtTokenProvider;
this.env = env;
}
@Override
protected void configure(HttpSecurity http) throws Exception {
if (isLocalMode()) {
setLocalMode(http);
} else {
setProdMode(http);
}
}
private boolean isLocalMode() {
String profile = env.getActiveProfiles().length > 0 ? env.getActiveProfiles()[0] : "";
return profile.equals("local");
}
private void setLocalMode(HttpSecurity http) throws Exception {
http
.csrf().disable()
.httpBasic().disable();
http
.headers()
.frameOptions()
.sameOrigin();
http
.authorizeRequests()
.antMatchers("/h2-console/*","favicon.ico").permitAll()
.antMatchers("/member/login").anonymous()
.antMatchers("/member/regist").anonymous()
.antMatchers("/member/validate/**").anonymous()
.anyRequest().authenticated()
.and()
.formLogin().disable()
.addFilterBefore(new JwtAuthFilter(jwtTokenProvider), UsernamePasswordAuthenticationFilter.class);
}
private void setProdMode(HttpSecurity http) throws Exception {
http
.csrf().disable()
.httpBasic().disable();
http
.authorizeRequests()
.antMatchers("/member/login").anonymous()
.antMatchers("/member/regist").anonymous()
.antMatchers("/member/validate/**").anonymous()
.anyRequest().authenticated()
.and()
.formLogin().disable()
.addFilterBefore(new JwtAuthFilter(jwtTokenProvider), UsernamePasswordAuthenticationFilter.class);
}
リファレンス
https://www.slipp.net/questions/546
Reference
この問題について(H2), 我々は、より多くの情報をここで見つけました https://velog.io/@hoyun7443/H2テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol