Skip to content

Instantly share code, notes, and snippets.

@samie
Last active November 8, 2016 06:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save samie/56a09e7301084514bcef to your computer and use it in GitHub Desktop.
Save samie/56a09e7301084514bcef to your computer and use it in GitHub Desktop.
Spring Initializr Vaadin demo app, https://start.spring.io/
package demo;
import com.vaadin.annotations.Theme;
import com.vaadin.server.VaadinRequest;
import com.vaadin.spring.annotation.SpringUI;
import com.vaadin.ui.Label;
import com.vaadin.ui.UI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.stereotype.Service;
@SpringBootApplication
public class DemoApplication {
// This is a runnable Spring Boot application
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
/* Business Service Facade.
* Annotate your business services with @Service and they
* will be autodetected by the framework.
*/
@Service
public static class MyService {
public String sayHi() {
return "Hello Spring Initializr!";
}
}
/* Vaadin UI class.
* Specify the theme and URI path for the
* web application.
*/
@Theme("valo")
@SpringUI(path = "")
public static class VaadinUI extends UI {
// You can easily autowire the services to you
// Vaadin applications
@Autowired
MyService myService;
@Override
protected void init(VaadinRequest request) {
setContent(new Label(myService.sayHi()));
}
}
}
@samie
Copy link
Author

samie commented Sep 17, 2015

There is also an another example with Spring Data, REST and server push: https://github.com/samie/spring-vaadin-demo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment