Skip to content

Commit

Permalink
Merge pull request #87 from aol/boot-merge
Browse files Browse the repository at this point in the history
Boot merge
  • Loading branch information
johnmcclean committed Dec 1, 2015
2 parents 9170654 + 860020d commit abeaf15
Show file tree
Hide file tree
Showing 35 changed files with 240 additions and 330 deletions.
1 change: 1 addition & 0 deletions micro-boot/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ dependencies {
testCompile project(':micro-client')
testCompile project(':micro-events')
testCompile project(':micro-jersey')
testCompile project(':micro-metrics')


}
Expand Down
62 changes: 59 additions & 3 deletions micro-boot/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,54 @@

[micro-boot example apps](https://github.com/aol/micro-server/tree/master/micro-boot/src/test/java/app)

Use Microserver and Spring Boot together.

## A simple example with one resource

* Annotate your classes with @Microboot to let Spring Boot know the base package for auto-scanning Spring beans.

* Create a MicroserverApp and run.

* You can now use the @Microserver annotation for configuration (except for base auto-scan packages)


```java
@Microboot //configure this package as the base for autoscan
//optionally use @Microserver here for more configuration options
public class SimpleExample {

RestClient rest = new RestClient(10_000,1_000);


public static void main (String[] args){

new MicroserverApp(()-> "simple-app").start();

assertThat(rest.get("http://localhost:8080/simple-app/status/ping"),equalTo("ok"));

}



}
@Rest
@Path("/status")
public class SimpleResource{



@GET
@Produces("text/plain")
@Path("/ping")
public String ping() {

return "ok";
}


}
```

## To use

[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.aol.microservices/micro-boot/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.aol.microservices/micro-boot)
Expand Down Expand Up @@ -40,13 +88,21 @@ Gradle
public class SimpleApp {

public static void main(String[] args){
new MicrobootApp(()->"test-app").run();
new MicroserverApp(()->"test-app").run();
}

}

# Relationship to Microserver and Spring Boot

micro-boot allows you to use Microserver plugins & jax-rs support with Spring Boot back ends.
micro-boot allows you to use Microserver plugins & jax-rs support with Spring Boot back ends.


@Microboot is simply syntax sugar for

```java
@Component
@SpringBootApplication(exclude = SpringDataWebAutoConfiguration.class)
```

micro-boot apps are started via the MicrobootApp (equivalent to MicroserverApp) and configured via the Microboot annotation (equivalent to the Microserver annotation)
You can also define your own SpringBoot configuration if required.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.aol.micro.server.boot.config;


import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
Expand All @@ -10,46 +9,10 @@
import org.springframework.boot.autoconfigure.data.web.SpringDataWebAutoConfiguration;
import org.springframework.stereotype.Component;

import com.aol.micro.server.config.Classes;

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Component
@SpringBootApplication(exclude = SpringDataWebAutoConfiguration.class)
public @interface Microboot{


/**
* @return Spring auto-scan base packages
*/
String[] basePackages() default {};

/**
* @return Classes to be passed to initial Spring context
* e.g. Classes that have Spring @Configuration or @Component annotation
*
*/
Class[] classes() default {};



/**
* @return Property file name
* default value is 'application.properties'
*/
String propertiesName() default "application.properties";

/**
* @return Hibernate entity scan packages
*/
String[] entityScan() default {};

/**
* @return Properties to be injected into spring format is
* key,value,key,value comma separated list
*/
String[] properties() default {};


}

}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.aol.micro.server.spring.boot;

import com.aol.micro.server.Plugin;
import com.aol.micro.server.spring.SpringBuilder;

/**
*
* @author johnmcclean
*
*/
public class BootPlugin implements Plugin{


/**
* @return Engine for building Spring Context
*/
public SpringBuilder springBuilder(){
return new BootApplicationConfigurator();
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
com.aol.micro.server.spring.boot.BootPlugin
Loading

0 comments on commit abeaf15

Please sign in to comment.