You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
965 B
33 lines
965 B
package xyz.wbsite.config;
|
|
|
|
import xyz.wbsite.frame.utils.ResourceUtil;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
import javax.annotation.PostConstruct;
|
|
import java.io.File;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Pattern;
|
|
|
|
@Configuration
|
|
public class SQLiteConfig {
|
|
|
|
@Value("${spring.datasource.url}")
|
|
private String url;
|
|
|
|
@PostConstruct
|
|
public void generateDB() {
|
|
Pattern compile = Pattern.compile("jdbc:sqlite:(.*.db).*");
|
|
Matcher matcher = compile.matcher(url);
|
|
if (matcher.find()) {
|
|
String group = matcher.group(1);
|
|
File file = new File(group);
|
|
if (!file.exists()) {
|
|
File path = file.getAbsoluteFile().getParentFile();
|
|
if (!path.exists()) path.mkdirs();
|
|
ResourceUtil.copyResource2File("nginx-admin.db", file);
|
|
}
|
|
}
|
|
}
|
|
}
|