A nano project to start a Vaadin project. Perfect for Micro-UIs packed as fat jar in a docker image.
This example is running from JDK8 up to JDK13
To support the Heroku pipeline we need a few preparations.
- the app must be able to get a configured port for the http port during the start up
- add the shade plugin to create a fat jar
- create the file Procfile and add the line
``web: java -jar target/vaadin-app.jar -port $PORT```
- web - to activate the web profile
- -jar - define what fat jar must be started
- -port make the dynamic associated port available for the app
- add a file settings.xml to configure the maven build process
The target of this project is a minimal rampup time for a first hello world. Why we need one more HelloWorld? Well, the answer is quite easy. If you have to try something out, or you want to make a small POC to present something, there is no time and budget to create a demo project. You don´t want to copy paste all small things together. Here you will get a Nano-Project that will give you all in a second.
Clone the repo and start editing the class HelloWorld
and VaadinApp
.
Nothing more.
Internally it will ramp up a Jetty. If you want to see how this is done, have a look inside
the class CoreUIService
.
You as a developer can use it like it is shown in the demo folder inside the src path.
public class HelloWorld {
public static void main(String[] args) {
new CoreUIService().startup();
}
}
@Route("")
public class VaadinApp extends Composite<Div> implements HasLogger {
public static final String BTN_CLICK_ME = "btn-click-me";
public static final String LB_CLICK_COUNT = "lb-click-count";
private final Button btnClickMe = new Button("click me");
private final Span lbClickCount = new Span("0");
private final VerticalLayout layout = new VerticalLayout(btnClickMe, lbClickCount);
private int clickcount = 0;
public VaadinApp() {
btnClickMe.setId(BTN_CLICK_ME);
btnClickMe.addClickListener(event -> lbClickCount.setText(String.valueOf(++clickcount)));
lbClickCount.setId(LB_CLICK_COUNT);
logger().info("and now.. setting the main content.. ");
getContent().add(layout);
}
}
Happy Coding.
if you have any questions: ping me on Twitter https://twitter.com/SvenRuppert or via mail.