12 November 2013

Spring Boot is a super impressive way to get started. Check out the various Getting Started guides for more on Spring Boot itself. Spring Boot exposes great metadata about the application from HTTP when you depend on the spring-boot-starter-actuator. Now, with M6, you can access that same information (and more!) from SSH! Here's a screencast I created demonstrating the feature. To enable it, you must also add the spring-boot-starter-shell-remote and spring-boot-starter-security.

Here's the code for the Groovy class that you can run by using the spring command line tool incantation: spring run foo.groovy:


@Grab("spring-boot-starter-shell-remote")
@Grab("spring-boot-starter-security")
@Grab("spring-boot-starter-actuator")
@RestController 
class RemoteShellFriendlyController {

  @RequestMapping("/users/{id}")
	Object someData( @PathVariable int id){
        [ someId : id ]
	}
	
}

In the screencast, I just use the default user and password. If you want use the same user and password from both SSH and HTTP, create a file application.properties and put it in the same directory as the Groovy script and put the following properties inside it:


security.user.name=youruser
security.user.password=yourpassword
shell.auth=spring