Application.java 1.38 KB
package etunicorn;

import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
<<<<<<< HEAD
import org.springframework.context.annotation.Bean;
=======
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;

import javax.sql.DataSource;
>>>>>>> 8cbe108cd842b37e3fe6c969ad942e5651d557b3

/**
 * Created by geoffrey on 28/01/17.
 */
@SpringBootApplication
@EnableAutoConfiguration
public class Application {

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

    @Bean
    public CommandLineRunner demo(PermissionRepository permissionRepository) {
        return (args) -> {
            permissionRepository.save(new Permission("ROLE_ADMIN"));
            permissionRepository.save(new Permission("CONSO_ADMIN"));
            permissionRepository.save(new Permission("EVNMT_ADMIN"));
            // ...
        };
    }

    public DataSource dataSource(){
        DataSourceBuilder dataSourceBuilder = DataSourceBuilder.create();
        dataSourceBuilder.driverClassName("org.sqlite.JDBC");
        dataSourceBuilder.url("jdbc:sqlite:etunicorn.db");
        return dataSourceBuilder.build();
    }
}