Testing environement variable

This commit is contained in:
BrokenFire 2017-12-12 19:41:35 +01:00
parent aa8784c218
commit cda8c1cc47
2 changed files with 12 additions and 2 deletions

View File

@ -10,6 +10,7 @@ import net.dv8tion.jda.core.entities.User;
import net.dv8tion.jda.core.events.message.MessageReceivedEvent; import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ExitCodeGenerator; import org.springframework.boot.ExitCodeGenerator;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
@ -24,7 +25,8 @@ import java.util.HashMap;
@SpringBootApplication @SpringBootApplication
public class MainBot { public class MainBot {
@Value("${name}")
public static String test;
public static final CommandParser parser =new CommandParser(); public static final CommandParser parser =new CommandParser();
public static HashMap<String, Commande> commandes = new HashMap<>(); public static HashMap<String, Commande> commandes = new HashMap<>();
public static HashMap<User, ArrayList<Message>> historique =new HashMap<>(); public static HashMap<User, ArrayList<Message>> historique =new HashMap<>();
@ -38,7 +40,7 @@ public class MainBot {
private static Logger logger = LogManager.getLogger(); private static Logger logger = LogManager.getLogger();
public static void main(String[] args) { public static void main(String[] args) {
ConfigurableApplicationContext ctx = SpringApplication.run(MainBot.class, args);
logger.trace("trace"); logger.trace("trace");
logger.debug("debug"); logger.debug("debug");
logger.info("info"); logger.info("info");
@ -63,12 +65,17 @@ public class MainBot {
} }
JDA jda = Init.initBot(token, dev); JDA jda = Init.initBot(token, dev);
ConfigurableApplicationContext ctx = SpringApplication.run(MainBot.class, args);
if(jda == null) { if(jda == null) {
System.exit(SpringApplication.exit(ctx, (ExitCodeGenerator) () -> { System.exit(SpringApplication.exit(ctx, (ExitCodeGenerator) () -> {
logger.fatal("Init error! Close application!"); logger.fatal("Init error! Close application!");
return 1; return 1;
})); }));
} }
logger.info(test);
} }
/*************************************** /***************************************
@ -106,6 +113,7 @@ public class MainBot {
logger.warn("Commande inconnue"); logger.warn("Commande inconnue");
} }
} }
/******************************* /*******************************
* RAZ Compteur Spam * * RAZ Compteur Spam *

View File

@ -0,0 +1,2 @@
#server.port={$PORT}
name = {$TEST}