├── README.md ├── pom.xml └── src └── main ├── java └── pl │ └── coffeecode │ └── boot │ └── sparkjava │ ├── Spark.java │ └── SparkConfiguration.java └── resources └── META-INF └── spring.factories /README.md: -------------------------------------------------------------------------------- 1 | # sparkjava-spring-boot-starter 2 | 3 | Project is currently not available in a public Maven repository. 4 | 5 | After cloning and installing locally: 6 | 7 | mvn clean install 8 | 9 | add following dependency: 10 | 11 | ```xml 12 | 13 | pl.coffeecode.boot 14 | sparkjava-spring-boot-starter 15 | 1.0 16 | 17 | ``` 18 | 19 | Getting started 20 | --------------- 21 | 22 | ```java 23 | import static spark.Spark.*; 24 | 25 | import org.springframework.beans.factory.annotation.Autowired; 26 | import org.springframework.core.annotation.Order; 27 | import org.springframework.stereotype.Component; 28 | import pl.coffeecode.boot.sparkjava.Spark; 29 | 30 | @Component 31 | @Order(value=1) 32 | public class HelloSpark implements Spark { 33 | 34 | @Autowired 35 | private HelloWorldService helloWorldService; 36 | 37 | @Override 38 | public void register() { 39 | get("/hello", (request, response) -> helloWorldService.hello() ); 40 | } 41 | 42 | } 43 | ``` 44 | 45 | 46 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.springframework.boot 6 | spring-boot-starter-parent 7 | 1.2.7.RELEASE 8 | 9 | 10 | pl.coffeecode.boot 11 | sparkjava-spring-boot-starter 12 | 1.0 13 | 14 | Spring Boot Spark Java 15 | https://github.com/pmackowski/sparkjava-spring-boot-starter 16 | 17 | 18 | 1.8 19 | 2.3 20 | 21 | 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter 26 | 27 | 28 | com.sparkjava 29 | spark-core 30 | ${spark-core.version} 31 | 32 | 33 | org.slf4j 34 | slf4j-api 35 | 36 | 37 | org.slf4j 38 | slf4j-simple 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/main/java/pl/coffeecode/boot/sparkjava/Spark.java: -------------------------------------------------------------------------------- 1 | package pl.coffeecode.boot.sparkjava; 2 | 3 | public interface Spark { 4 | 5 | /** 6 | * adds filters, routes, exceptions, websockets and others 7 | */ 8 | void register(); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/pl/coffeecode/boot/sparkjava/SparkConfiguration.java: -------------------------------------------------------------------------------- 1 | package pl.coffeecode.boot.sparkjava; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.boot.CommandLineRunner; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | @Configuration 12 | public class SparkConfiguration { 13 | 14 | @Autowired(required = false) 15 | private List sparks = new ArrayList<>(); 16 | 17 | @Bean 18 | CommandLineRunner sparkRunner() { 19 | return args -> sparks.stream().forEach( spark -> spark.register()); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=pl.coffeecode.boot.sparkjava.SparkConfiguration --------------------------------------------------------------------------------