-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
197 additions
and
73 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
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
29 changes: 29 additions & 0 deletions
29
src/main/java/stirling/software/SPDF/config/security/database/DataSourceConfig.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,29 @@ | ||
package stirling.software.SPDF.config.security.database; | ||
|
||
import javax.sql.DataSource; | ||
|
||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.boot.jdbc.DataSourceBuilder; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
@Configuration | ||
@ConfigurationProperties(prefix = "spring.datasource") | ||
public class DataSourceConfig { | ||
|
||
private String driverClassName; | ||
private String url; | ||
private String username; | ||
private String password; | ||
|
||
public DataSource dataSource() { | ||
DataSourceBuilder<?> dataSourceBuilder = DataSourceBuilder.create(); | ||
dataSourceBuilder.driverClassName(driverClassName); | ||
dataSourceBuilder.url(url); | ||
dataSourceBuilder.username(username); | ||
dataSourceBuilder.password(password); | ||
return dataSourceBuilder.build(); | ||
} | ||
} |
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
35 changes: 35 additions & 0 deletions
35
src/main/java/stirling/software/SPDF/config/security/database/DatabaseConfig.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,35 @@ | ||
package stirling.software.SPDF.config.security.database; | ||
|
||
import java.sql.Connection; | ||
import java.sql.DriverManager; | ||
import java.sql.SQLException; | ||
|
||
import javax.sql.DataSource; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
@Configuration | ||
public class DatabaseConfig { | ||
|
||
@Autowired private DataSourceConfig dataSourceConfig; | ||
|
||
@Autowired private JpaConfig jpaConfig; | ||
|
||
@Bean | ||
public DataSource dataSource() { | ||
return dataSourceConfig.dataSource(); | ||
} | ||
|
||
@Bean | ||
public Connection connection() throws SQLException { | ||
return DriverManager.getConnection( | ||
dataSourceConfig.getUrl(), | ||
dataSourceConfig.getUsername(), | ||
dataSourceConfig.getPassword()); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/stirling/software/SPDF/config/security/database/JpaConfig.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,20 @@ | ||
package stirling.software.SPDF.config.security.database; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
@Configuration | ||
@ConfigurationProperties(prefix = "spring.jpa") | ||
public class JpaConfig { | ||
|
||
@Value("${environment.name}") | ||
private String environmentName; | ||
|
||
private String databasePlatform; | ||
private String openInView; | ||
private String generateDDL; | ||
} |
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
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
Oops, something went wrong.