-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
h2サーバー起動用のクラスをインフラから削除し、adminとconsumerに新規追加
- Loading branch information
1 parent
f5749a3
commit 00f9057
Showing
6 changed files
with
43 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...infrastructure/config/H2ServerConfig.java → ...ssca/web/admin/config/H2ServerConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
...-backend/web-consumer/src/main/java/com/dressca/web/consumer/config/DresscaWebConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...ca-backend/web-consumer/src/main/java/com/dressca/web/consumer/config/H2ServerConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.dressca.web.consumer.config; | ||
|
||
import org.h2.tools.Server; | ||
import org.springframework.context.annotation.Profile; | ||
import org.springframework.stereotype.Component; | ||
import jakarta.annotation.PostConstruct; | ||
import jakarta.annotation.PreDestroy; | ||
import java.sql.SQLException; | ||
|
||
/** | ||
* 開発環境でh2データベースを立ち上げるためのクラスです。 | ||
*/ | ||
@Component | ||
@Profile("local") | ||
public class H2ServerConfig { | ||
|
||
private Server tcpServer; | ||
|
||
/** | ||
* h2サーバをサーバーモードで起動します。 | ||
*/ | ||
@PostConstruct | ||
public void start() { | ||
try { | ||
this.tcpServer = Server.createTcpServer("-tcpPort", "9092", "-tcpAllowOthers", "-ifNotExists").start(); | ||
} catch (SQLException e) { | ||
System.out.println("H2 server is already started."); | ||
} | ||
} | ||
|
||
/** | ||
* h2サーバを停止します。 | ||
*/ | ||
@PreDestroy | ||
public void stop() { | ||
if (this.tcpServer != null) { | ||
this.tcpServer.stop(); | ||
} | ||
} | ||
} |