Server/src/main/java/de/towerdefence/server/ServerApplication.java
Snoweuph 5b2500010f
Some checks failed
Quality Check / Validate OAS (push) Successful in 38s
Build Application / build (push) Successful in 1m6s
Build Application / build-docker (push) Failing after 10s
Build Application / release (push) Has been skipped
Quality Check / Linting (push) Successful in 1m6s
Quality Check / Testing (push) Successful in 1m1s
Quality Check / Static Analysis (push) Successful in 1m2s
chore: setup
2025-02-01 14:47:47 +01:00

50 lines
1.7 KiB
Java

package de.towerdefence.server;
import io.swagger.configuration.LocalDateConverter;
import io.swagger.configuration.LocalDateTimeConverter;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.ExitCodeGenerator;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import java.io.Serial;
@SpringBootApplication
@ComponentScan(basePackages = { "de.towerdefence.server", "de.towerdefence.server.oas" , "io.swagger.configuration"})
public class ServerApplication implements CommandLineRunner {
@Override
public void run(String... arg0) throws Exception {
if (arg0.length > 0 && arg0[0].equals("exitcode")) {
throw new ExitException();
}
}
public static void main(String[] args) throws Exception {
new SpringApplication(ServerApplication.class).run(args);
}
@Configuration
static class CustomDateConfig extends WebMvcConfigurationSupport {
@Override
public void addFormatters(FormatterRegistry registry) {
registry.addConverter(new LocalDateConverter("yyyy-MM-dd"));
registry.addConverter(new LocalDateTimeConverter("yyyy-MM-dd'T'HH:mm:ss.SSS"));
}
}
static class ExitException extends RuntimeException implements ExitCodeGenerator {
@Serial
private static final long serialVersionUID = 1L;
@Override
public int getExitCode() {
return 10;
}
}
}