feat: 增加外部配置项
This commit is contained in:
14
.gitignore
vendored
14
.gitignore
vendored
@@ -5,18 +5,6 @@ build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
bin/
|
||||
!**/src/main/**/bin/
|
||||
!**/src/test/**/bin/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
@@ -41,4 +29,4 @@ out/
|
||||
|
||||
### Database ###
|
||||
*.db
|
||||
database.json
|
||||
database
|
||||
1
scripts/start.bat
Normal file
1
scripts/start.bat
Normal file
@@ -0,0 +1 @@
|
||||
C:\Users\Administrator\.jdks\jdk-17.0.12+7\bin\java -jar digital-market-0.0.1.jar --messenger.driver.driver-path=C:\Users\Administrator\IdeaProjects\appdriver\chrome\chromedriver.exe --messenger.driver.binary-path=C:\Users\Administrator\IdeaProjects\appdriver\chrome\chromium\chrome.exe
|
||||
@@ -2,11 +2,11 @@ package com.lanyuanxiaoyao.digtal.market
|
||||
|
||||
import com.lanyuanxiaoyao.digtal.market.runner.NewsRunner
|
||||
import com.lanyuanxiaoyao.digtal.market.runner.PushRunner
|
||||
import com.lanyuanxiaoyao.digtal.market.sender.DingtalkSender
|
||||
import com.lanyuanxiaoyao.squirrel.core.common.Management
|
||||
import com.lanyuanxiaoyao.squirrel.core.jvm.BINARY_PATH
|
||||
import com.lanyuanxiaoyao.squirrel.core.jvm.DRIVER_PATH
|
||||
import com.lanyuanxiaoyao.squirrel.core.jvm.JvmManagement
|
||||
import com.lanyuanxiaoyao.squirrel.core.jvm.LocalFileDatabase
|
||||
import jakarta.annotation.Resource
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.boot.ApplicationArguments
|
||||
@@ -24,6 +24,12 @@ import org.springframework.scheduling.annotation.EnableScheduling
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer
|
||||
|
||||
@ConfigurationProperties(prefix = "messenger.database")
|
||||
data class DatabaseProperties @ConstructorBinding constructor(
|
||||
val h2Path: String,
|
||||
val jsonPath: String,
|
||||
)
|
||||
|
||||
@ConfigurationProperties(prefix = "messenger.driver")
|
||||
data class DriverProperties @ConstructorBinding constructor(
|
||||
val driverPath: String,
|
||||
@@ -53,7 +59,7 @@ class Application : ApplicationRunner, ApplicationListener<ContextClosedEvent> {
|
||||
|
||||
override fun run(args: ApplicationArguments?) {
|
||||
// pushRunner.run()
|
||||
newsRunner.run()
|
||||
// newsRunner.run()
|
||||
}
|
||||
|
||||
override fun onApplicationEvent(event: ContextClosedEvent) {
|
||||
@@ -65,7 +71,12 @@ class Application : ApplicationRunner, ApplicationListener<ContextClosedEvent> {
|
||||
@ExperimentalStdlibApi
|
||||
class Configuration {
|
||||
@Bean
|
||||
fun jvmManagement(driverProperties: DriverProperties): Management = JvmManagement().also { management ->
|
||||
fun jvmManagement(
|
||||
driverProperties: DriverProperties,
|
||||
databaseProperties: DatabaseProperties
|
||||
): Management = JvmManagement(
|
||||
database = LocalFileDatabase(databaseProperties.jsonPath)
|
||||
).also { management ->
|
||||
management
|
||||
.fetchConfiguration()
|
||||
.let { information ->
|
||||
|
||||
@@ -14,7 +14,7 @@ spring:
|
||||
ssl:
|
||||
enable: true
|
||||
datasource:
|
||||
url: jdbc:h2:./database.db;MODE=MySQL;DATABASE_TO_LOWER=TRUE;CASE_INSENSITIVE_IDENTIFIERS=TRUE
|
||||
url: jdbc:h2:${messenger.database.h2-path};MODE=MySQL;DATABASE_TO_LOWER=TRUE;CASE_INSENSITIVE_IDENTIFIERS=TRUE
|
||||
username: lanyuanxiaoyao
|
||||
password: lanyuanxiaoyao
|
||||
driver-class-name: org.h2.Driver
|
||||
@@ -36,3 +36,6 @@ messenger:
|
||||
driver:
|
||||
driver-path: /Users/lanyuanxiaoyao/Downloads/chromium/128/macOS-1289987/chromedriver
|
||||
binary-path: /Users/lanyuanxiaoyao/Downloads/chromium/128/macOS-1289987/Chromium.app/Contents/MacOS/Chromium
|
||||
database:
|
||||
h2-path: ./database/database.db
|
||||
json-path: ./database/database.json
|
||||
Reference in New Issue
Block a user