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.

30 lines
920 B

package ${basePackage}.config;
import org.springframework.context.annotation.Configuration;
import ${basePackage}.frame.utils.Properties;
import ${basePackage}.frame.utils.ResourceUtil;
import javax.annotation.PostConstruct;
import java.io.File;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Configuration
public class SQLiteConfig {
@PostConstruct
public void generateDB() {
Pattern compile = Pattern.compile("jdbc:sqlite:(.*.db).*");
Matcher matcher = compile.matcher(Properties.datasourceUrl);
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);
}
}
}
}

Powered by TurnKey Linux.