http service: use spring datasource configuration

This commit is contained in:
Adam
2019-02-17 10:05:39 -05:00
parent fe2eba06a7
commit 2a41d88c29
7 changed files with 146 additions and 70 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* Copyright (c) 2019, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -24,57 +24,23 @@
*/
package net.runelite.http.service;
import java.time.Instant;
import java.util.HashMap;
import java.util.Map;
import javax.naming.NamingException;
import net.runelite.http.service.util.InstantConverter;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.sql2o.Sql2o;
import org.sql2o.converters.Converter;
import org.sql2o.quirks.NoQuirks;
@SpringBootApplication
@EnableScheduling
public class SpringBootWebApplicationTest
{
@Bean("Runelite SQL2O")
Sql2o sql2o()
{
Map<Class, Converter> converters = new HashMap<>();
converters.put(Instant.class, new InstantConverter());
return new Sql2o("jdbc:mysql://192.168.1.2/runelite", "runelite", "runelite", new NoQuirks(converters));
}
@Bean("Runelite Cache SQL2O")
Sql2o cacheSql2o() throws NamingException
{
Map<Class, Converter> converters = new HashMap<>();
converters.put(Instant.class, new InstantConverter());
return new Sql2o("jdbc:mysql://192.168.1.2/cache", "runelite", "runelite", new NoQuirks(converters));
}
@Bean("Runelite XP Tracker SQL2O")
Sql2o xpSql2o() throws NamingException
{
Map<Class, Converter> converters = new HashMap<>();
converters.put(Instant.class, new InstantConverter());
return new Sql2o("jdbc:mysql://192.168.1.2/xptracker", "runelite", "runelite", new NoQuirks(converters));
}
@Test
@Ignore
public void test() throws InterruptedException
public void run() throws InterruptedException
{
SpringApplication.run(SpringBootWebApplicationTest.class, new String[0]);
String[] args = new String[]{
"--spring.config.location=classpath:/application.yaml,classpath:/dev.yaml"
};
SpringApplication.run(SpringBootWebApplication.class, args);
for (;;)
{
Thread.sleep(100L);
}
}
}
}

View File

@@ -1,10 +0,0 @@
oauth.client-id=moo
oauth.client-secret=cow
minio.endpoint=http://10.96.22.171:9000
minio.accesskey=AM54M27O4WZK65N6F8IP
minio.secretkey=/PZCxzmsJzwCHYlogcymuprniGCaaLUOET2n6yMP
minio.bucket=runelite
runelite.twitter.consumerkey=moo
runelite.twitter.secretkey=cow
runelite.twitter.listid=968949795153948673
logging.level.net.runelite=DEBUG

View File

@@ -0,0 +1,35 @@
oauth:
client-id: moo
client-secret: cow
minio:
endpoint: http://10.96.22.171:9000
accesskey: AM54M27O4WZK65N6F8IP
secretkey: /PZCxzmsJzwCHYlogcymuprniGCaaLUOET2n6yMP
bucket: runelite
runelite:
twitter:
consumerkey: moo
secretkey: cow
listid: 968949795153948673
logging:
level:
net:
runelite:
DEBUG
datasource:
runelite:
driverClassName: org.h2.Driver
type: org.h2.jdbcx.JdbcDataSource
url: jdbc:h2:mem:runelite
runelite-cache:
driverClassName: org.h2.Driver
type: org.h2.jdbcx.JdbcDataSource
url: jdbc:h2:mem:cache
runelite-tracker:
driverClassName: org.h2.Driver
type: org.h2.jdbcx.JdbcDataSource
url: jdbc:h2:mem:xptracker

View File

@@ -0,0 +1,19 @@
datasource:
runelite:
driverClassName: com.mysql.jdbc.Driver
type: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
url: jdbc:mysql://192.168.1.2/runelite
username: runelite
password: runelite
runelite-cache:
driverClassName: com.mysql.jdbc.Driver
type: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
url: jdbc:mysql://192.168.1.2/cache
username: runelite
password: runelite
runelite-tracker:
driverClassName: com.mysql.jdbc.Driver
type: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
url: jdbc:mysql://192.168.1.2/xptracker
username: runelite
password: runelite