Skip to content

Commit

Permalink
ensure coding-ide-home exist
Browse files Browse the repository at this point in the history
  • Loading branch information
tanhe123 committed Sep 22, 2016
1 parent e769709 commit b76916c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
9 changes: 0 additions & 9 deletions src/main/java/net/coding/ide/Application.java
Expand Up @@ -24,21 +24,12 @@ public class Application {
@Value("${PTY_LIB_FOLDER}")
private String ptyLibFolder;

@Value("${CODING_IDE_HOME}")
private String codingIdeHome;

public static void main(String[] args) throws URISyntaxException {
SpringApplication.run(Application.class, args);
}

@PostConstruct
public void init() throws IOException {
System.setProperty("PTY_LIB_FOLDER", ptyLibFolder);

File file = new File(codingIdeHome);

if (!file.exists()) {
Files.createDirectories(file.toPath());
}
}
}
19 changes: 19 additions & 0 deletions src/main/java/net/coding/ide/config/JpaConfig.java
Expand Up @@ -14,7 +14,11 @@
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import javax.annotation.PostConstruct;
import javax.sql.DataSource;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;

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

@Value("${CODING_IDE_HOME}")
private String codingIdeHome;

@PostConstruct
public void init() throws IOException {

File file = new File(codingIdeHome);

if (!file.exists()) {
Files.createDirectories(file.toPath());
}
}

@Bean
public DataSource dataSource() {
DataSourceBuilder dataSourceBuilder = DataSourceBuilder.create();
Expand All @@ -44,4 +61,6 @@ public DataSource dataSource() {
dataSourceBuilder.type(HikariDataSource.class);
return dataSourceBuilder.build();
}


}

0 comments on commit b76916c

Please sign in to comment.