
templates.demos.helloWorld.quick.html Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spincast-website Show documentation
Show all versions of spincast-website Show documentation
Source code for the https://www.spincast.org website.
{% extends "../helloWorld.html" %}
{% block demoSectionClasses %}demo_hello_world_quick{% endblock %}
{% block meta_title %}Demo - Hello World - Quick{% endblock %}
{% block meta_description %}"Hello World!" demo and tutorial using Spincast - Quick version{% endblock %}
{% set demoId = "quick" %}
{% block demoBody %}
1. Quick version!
First, we add the latest version of the org.spincast:spincast-default
Maven artifact to our pom.xml
(or build.gradle
) :
<dependency>
<groupId>org.spincast</groupId>
<artifactId>spincast-default</artifactId>
<version>{{spincast.spincastCurrrentVersion}}</version>
</dependency>
Then :
public class App {
public static void main(String[] args) {
Spincast.init(args);
}
@Inject
protected void init(DefaultRouter router, Server server) {
router.GET("/").handle(context -> context.response().sendHtml("<h1>Hello World!</h1>"));
server.start();
}
}
Explanation :
(
Tip : try hovering/clicking the page numbers below! )
-
3 : A standard
main(...)
method is the entry point of our application.
-
4 :
Spincast.init(args)
will
create a Guice context using the default plugins, will
bind the current App
class in the context and will load it.
-
7-8 : This init method
is going to be called automatically when the Guice context is ready. We inject in it the
default Router and the
default Server.
-
9 : We define a
Route
for the index page
using an inline Route Handler
based on a lambda.
-
10 : We start the server.
Try it!
Download this application, and run it by yourself :
-
Download spincast-demos-quick.zip.
-
Unzip the file.
-
Enter the root directory using a terminal.
-
Compile the application using Maven :
mvn clean package
-
Launch the application :
java -jar target/spincast-demos-quick-{{spincast.spincastCurrrentVersion}}.jar
The application is then accessible at http://localhost:44419
Too simple for you?
Try the Better... "Hello World!" demo, for an improved version!
{% endblock %}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy