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
981 B
33 lines
981 B
5 years ago
|
package ${basePackage}.config;
|
||
|
|
||
|
import ${basePackage}.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 setSharedVariable() {
|
||
|
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("${projectName}.db", file);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|