Skip to content

Commit b76916c

Browse files
committed
ensure coding-ide-home exist
1 parent e769709 commit b76916c

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

src/main/java/net/coding/ide/Application.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,12 @@ public class Application {
2424
@Value("${PTY_LIB_FOLDER}")
2525
private String ptyLibFolder;
2626

27-
@Value("${CODING_IDE_HOME}")
28-
private String codingIdeHome;
29-
3027
public static void main(String[] args) throws URISyntaxException {
3128
SpringApplication.run(Application.class, args);
3229
}
3330

3431
@PostConstruct
3532
public void init() throws IOException {
3633
System.setProperty("PTY_LIB_FOLDER", ptyLibFolder);
37-
38-
File file = new File(codingIdeHome);
39-
40-
if (!file.exists()) {
41-
Files.createDirectories(file.toPath());
42-
}
4334
}
4435
}

src/main/java/net/coding/ide/config/JpaConfig.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
1515
import org.springframework.transaction.annotation.EnableTransactionManagement;
1616

17+
import javax.annotation.PostConstruct;
1718
import javax.sql.DataSource;
19+
import java.io.File;
20+
import java.io.IOException;
21+
import java.nio.file.Files;
1822

1923
/**
2024
* Created by vangie on 14/12/4.
@@ -36,6 +40,19 @@ public class JpaConfig {
3640
@Value("${spring.datasource.driver-class-name}")
3741
private String driverClassName;
3842

43+
@Value("${CODING_IDE_HOME}")
44+
private String codingIdeHome;
45+
46+
@PostConstruct
47+
public void init() throws IOException {
48+
49+
File file = new File(codingIdeHome);
50+
51+
if (!file.exists()) {
52+
Files.createDirectories(file.toPath());
53+
}
54+
}
55+
3956
@Bean
4057
public DataSource dataSource() {
4158
DataSourceBuilder dataSourceBuilder = DataSourceBuilder.create();
@@ -44,4 +61,6 @@ public DataSource dataSource() {
4461
dataSourceBuilder.type(HikariDataSource.class);
4562
return dataSourceBuilder.build();
4663
}
64+
65+
4766
}

0 commit comments

Comments
 (0)