{"id":55653,"date":"2018-02-26T15:00:54","date_gmt":"2018-02-26T13:00:54","guid":{"rendered":"http:\/\/examples.javacodegeeks.com\/?p=55653"},"modified":"2019-04-09T12:54:19","modified_gmt":"2019-04-09T09:54:19","slug":"vaadin-spring-example","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-spring-example\/","title":{"rendered":"Vaadin Spring Example"},"content":{"rendered":"<h2>1. Introduction<\/h2>\n<p><a href=\"https:\/\/vaadin.com\/home\" target=\"_blank\" rel=\"noopener noreferrer\">Vaadin<\/a>&nbsp;is a web application framework written in Java, and is built on&nbsp;<a href=\"http:\/\/www.gwtproject.org\/overview.html\" target=\"_blank\" rel=\"noopener noreferrer\">Google Web Toolkit<\/a>&nbsp;from&nbsp;<a href=\"https:\/\/vaadin.com\/company\" target=\"_blank\" rel=\"noopener noreferrer\">Vaadin Ltd.<\/a><\/p>\n<p><a href=\"https:\/\/projects.spring.io\/spring-framework\/\" target=\"_blank\" rel=\"noopener noreferrer\">Spring Framework<\/a>&nbsp;is a Java application framework that provides many useful services for building applications.<\/p>\n<p><a href=\"https:\/\/vaadin.com\/home\" target=\"_blank\" rel=\"noopener noreferrer\">Vaadin<\/a>&nbsp;provides a&nbsp;<a href=\"https:\/\/vaadin.com\/directory\/component\/vaadin-spring\" target=\"_blank\" rel=\"noopener noreferrer\">Vaadin Spring<\/a> add-on based on the core parts of&nbsp;<a href=\"https:\/\/mvnrepository.com\/artifact\/org.vaadin.spring\" target=\"_blank\" rel=\"noopener noreferrer\">vaadin4spring<\/a> to make&nbsp;classes for UI and View as Spring managed beans so <a href=\"https:\/\/docs.spring.io\/spring\/docs\/current\/spring-framework-reference\/core.html\" target=\"_blank\" rel=\"noopener noreferrer\">Spring dependency injection<\/a> can be used.<\/p>\n<p>In this example, I will demonstrate how to build a Single Paged Application (SPA) with <a href=\"https:\/\/vaadin.com\/api\/vaadin-spring\/\" target=\"_blank\" rel=\"noopener noreferrer\">Vaadin Spring<\/a>.\n<\/p>\n<h2>2. Technologies Used<\/h2>\n<p>The example code in this article was built and run using:<\/p>\n<ul>\n<li>Java 1.8.101 (1.8.x will do fine)<\/li>\n<li>Maven 3.3.9 (3.3.x will do fine)<\/li>\n<li>Eclipse Mars (Any Java IDE would work)<\/li>\n<li>Vaadin 8.3.0 (7.x will do fine)<\/li>\n<li>Vaadin Spring Boot 1.5.10.RELEASE<\/li>\n<\/ul>\n<h2>3. Spring-boot Vaadin Web Application<\/h2>\n<p>The easiest way to generate a Spring-boot Vaadin application is via the Spring starter tool with the steps below:<\/p>\n<ol>\n<li>Go to&nbsp;<code>https:\/\/start.spring.io\/<\/code>.<\/li>\n<li>Select <code>Maven Project<\/code> with <code>Java<\/code> and Spring Boot version 1.5.10 and type in&nbsp;<code>Vaadin<\/code>&nbsp;in the &#8220;search for dependencies&#8221;&nbsp; bar.<\/li>\n<li>Enter the group name as <code>jcg.zheng.demo<\/code> and artifact as&nbsp;<code>vaadin-spring-demo<\/code>.<\/li>\n<li>Click the&nbsp;<code>Generate Project<\/code> button.<\/li>\n<\/ol>\n<p><figure id=\"attachment_55714\" aria-describedby=\"caption-attachment-55714\" style=\"width: 800px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/vaadin-spring.jpg\"><img decoding=\"async\" class=\"size-full wp-image-55714\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/vaadin-spring.jpg\" alt=\"Generate Vaadin spring-boot Project\" width=\"800\" height=\"429\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/vaadin-spring.jpg 800w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/vaadin-spring-300x160.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/vaadin-spring-768x412.jpg 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><figcaption id=\"caption-attachment-55714\" class=\"wp-caption-text\">Figure 1 Generate Vaadin spring-boot Project<\/figcaption><\/figure><\/p>\n<p>A maven project will be generated and downloaded to your workstation. Import it into your Eclipse workspace.<\/p>\n<h3>3.1 POM<\/h3>\n<p>The generated&nbsp;<code>pom.xml<\/code> includes&nbsp;<code>vaadin-spring-boot-starter<\/code>. There is no modification needed in this example.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>pom.xml<\/em><\/span><\/p>\n<pre class=\"brush:xml; wrap-lines:false\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;project xmlns=\"http:\/\/maven.apache.org\/POM\/4.0.0\" xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\n\txsi:schemaLocation=\"http:\/\/maven.apache.org\/POM\/4.0.0 http:\/\/maven.apache.org\/xsd\/maven-4.0.0.xsd\"&gt;\n\t&lt;modelVersion&gt;4.0.0&lt;\/modelVersion&gt;\n\n\t&lt;groupId&gt;jcg.zheng.demo&lt;\/groupId&gt;\n\t&lt;artifactId&gt;vaadin-spring-demo&lt;\/artifactId&gt;\n\t&lt;version&gt;0.0.1-SNAPSHOT&lt;\/version&gt;\n\t&lt;packaging&gt;jar&lt;\/packaging&gt;\n\n\t&lt;name&gt;vaadin-spring-demo&lt;\/name&gt;\n\t&lt;description&gt;Demo project for Spring Boot&lt;\/description&gt;\n\n\t&lt;parent&gt;\n\t\t&lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\n\t\t&lt;artifactId&gt;spring-boot-starter-parent&lt;\/artifactId&gt;\n\t\t&lt;version&gt;1.5.10.RELEASE&lt;\/version&gt;\n\t\t&lt;relativePath\/&gt; &lt;!-- lookup parent from repository --&gt;\n\t&lt;\/parent&gt;\n\n\t&lt;properties&gt;\n\t\t&lt;project.build.sourceEncoding&gt;UTF-8&lt;\/project.build.sourceEncoding&gt;\n\t\t&lt;project.reporting.outputEncoding&gt;UTF-8&lt;\/project.reporting.outputEncoding&gt;\n\t\t&lt;java.version&gt;1.8&lt;\/java.version&gt;\n\t\t&lt;vaadin.version&gt;8.3.0&lt;\/vaadin.version&gt;\n\t&lt;\/properties&gt;\n\n\t&lt;dependencies&gt;\n\t\t&lt;dependency&gt;\n\t\t\t&lt;groupId&gt;com.vaadin&lt;\/groupId&gt;\n\t\t\t&lt;artifactId&gt;vaadin-spring-boot-starter&lt;\/artifactId&gt;\n\t\t&lt;\/dependency&gt;\n\n\t\t&lt;dependency&gt;\n\t\t\t&lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\n\t\t\t&lt;artifactId&gt;spring-boot-starter-test&lt;\/artifactId&gt;\n\t\t\t&lt;scope&gt;test&lt;\/scope&gt;\n\t\t&lt;\/dependency&gt;\n\t&lt;\/dependencies&gt;\n\n\t&lt;dependencyManagement&gt;\n\t\t&lt;dependencies&gt;\n\t\t\t&lt;dependency&gt;\n\t\t\t\t&lt;groupId&gt;com.vaadin&lt;\/groupId&gt;\n\t\t\t\t&lt;artifactId&gt;vaadin-bom&lt;\/artifactId&gt;\n\t\t\t\t&lt;version&gt;${vaadin.version}&lt;\/version&gt;\n\t\t\t\t&lt;type&gt;pom&lt;\/type&gt;\n\t\t\t\t&lt;scope&gt;import&lt;\/scope&gt;\n\t\t\t&lt;\/dependency&gt;\n\t\t&lt;\/dependencies&gt;\n\t&lt;\/dependencyManagement&gt;\n\n\t&lt;build&gt;\n\t\t&lt;plugins&gt;\n\t\t\t&lt;plugin&gt;\n\t\t\t\t&lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\n\t\t\t\t&lt;artifactId&gt;spring-boot-maven-plugin&lt;\/artifactId&gt;\n\t\t\t&lt;\/plugin&gt;\n\t\t&lt;\/plugins&gt;\n\t&lt;\/build&gt;\n\n\n&lt;\/project&gt;\n<\/pre>\n<h3>3.2 Vaadin Spring Demo Application<\/h3>\n<p>The generated <code>VaadinSpringDemoApplication.java<\/code> is annotated with <code>@SpringBootApplication<\/code>.&nbsp;It is equivalent to using&nbsp;&nbsp;<code>@Configuration<\/code>,&nbsp;<code>@EnableAutoConfiguration<\/code>,&nbsp;and&nbsp;<code>@ComponentScan<\/code>with their default attributes. In this example there is also no modification needed.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>VaadinSpringDemoApplication.java<\/em><\/span><\/p>\n<pre class=\"brush:java; wrap-lines:false\">package jcg.zheng.demo.spring;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure.SpringBootApplication;\n\n@SpringBootApplication\npublic class VaadinSpringDemoApplication {\n\n\tpublic static void main(String[] args) {\n\t\tSpringApplication.run(VaadinSpringDemoApplication.class, args);\n\t}\n}\n<\/pre>\n<p>Execute <code>mvn clean install<\/code> to build the project. You should be able to start it as a Java Application.<\/p>\n<h2>4. Single Paged Vaadin&nbsp;Application<\/h2>\n<p>If you have not worked with Vaadin before, please check it out&nbsp;<a href=\"https:\/\/vaadin.com\/docs\/framework\/tutorial.html\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a>.<\/p>\n<p>Vaadin-Spring add-on API includes the annotations below:<\/p>\n<ul>\n<li>@SpringComponent<\/li>\n<li>@SpringUI<\/li>\n<li>@SpringView<\/li>\n<li>@SpringViewDisplay<\/li>\n<li>@UIScope<\/li>\n<li>@VaadinSessionScope<\/li>\n<li>@ViewScope<\/li>\n<\/ul>\n<p>The easiest way to set up your navigation in a SPA is to use the <code>@SpringViewDisplay<\/code>&nbsp;on the UI class, in which case the whole contents of the UI is replaced based on the navigation. In this example, we will create a main UI class, which contains two navigation buttons. It will switch to the dedicated view when the correct button is clicked.<\/p>\n<h3>4.1 Spring Beans<\/h3>\n<p>Vaadin Spring <code>@SpringComponent<\/code>&nbsp;annotation allows for automatic detection of beans managed by Spring.<\/p>\n<p>In case you were wondering, <code>@SpringComponent<\/code> is exactly the same as the regular Spring&nbsp;<code>@Component<\/code>, but has been given an alias, because Vaadin already has a&nbsp;<code>Component<\/code>&nbsp;interface.<\/p>\n<p>In this example, we will create two Spring Beans, annotate them with <code>@ViewScope<\/code> and <code>@UIScope<\/code> respectively.<\/p>\n<h4>4.1.1 Bean with @ViewScope<\/h4>\n<p>The lifecycle of View-scoped beans starts when the user navigates to a view referring to the object and ends when the user navigates out of the view or when the UI is closed or expires.<\/p>\n<p>In this step, we will create <code>DemoViewScopeBean<\/code> with <code>@ViewScope<\/code> annotation. This bean will be used later at <a href=\"#heading421\">step 4.2.1<\/a>.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>DemoViewScopeBean.java<\/em><\/span><\/p>\n<pre class=\"brush:java; wrap-lines:false\">package jcg.zheng.demo.spring;\n\nimport com.vaadin.spring.annotation.SpringComponent;\nimport com.vaadin.spring.annotation.ViewScope;\n\n@SpringComponent\n@ViewScope\npublic class DemoViewScopeBean {\n\tpublic String getData() {\n\t\treturn \"Same bean instance for same view. bean=\"\n\t\t\t\t+ toString();\n\n\t}\n}<\/pre>\n<h4>4.1.2 Bean with @UIScope<\/h4>\n<p>The lifecycle of UI-scoped beans is bound between the initialization and closing of a UI. UI-scoped beans are uniquely identified within a UI instance, that is, a browser window or tab. When injecting a bean, the same instance bean will be used if&nbsp;within the same UI.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p>In this step, we will create <code>DemoUIScopeBean<\/code> with <code>@UIScope<\/code> annotation. This bean will be used later at steps <a href=\"#heading421\">4.2.1<\/a> and <a href=\"#heading422\">4.2.2<\/a>.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>DemoUIScopeBean.java<\/em><\/span><\/p>\n<pre class=\"brush:java; wrap-lines:false\">package jcg.zheng.demo.spring;\n\nimport com.vaadin.spring.annotation.SpringComponent;\nimport com.vaadin.spring.annotation.UIScope;\n\n@SpringComponent\n@UIScope\npublic class DemoUIScopeBean {\n\tpublic String getData() {\n\t\treturn \"Same bean instance for same UI. bean=\" + toString();\n\t}\n}<\/pre>\n<h3>4.2 Spring Views<\/h3>\n<p>The&nbsp;<code>@SpringView<\/code> annotation enables Spring injection features in the view classes.&nbsp;The&nbsp;<code>SpringViewProvider<\/code> fetches the views from the Spring application context and&nbsp;registers them so that these views can be managed by <code>@SpringViewDisplay<\/code>.<\/p>\n<p>In this step, we will create <code>ViewScopeView<\/code> and <code>DefaultView<\/code>&nbsp;and annotate them with <code>@ViewScope<\/code> and&nbsp;<code>UIScopeView<\/code> and <code>ErrorView<\/code>&nbsp;and annotate them with <code>@UIScope<\/code>.<\/p>\n<h4><a name=\"headin421\"><\/a>4.2.1 View with @ViewScope<\/h4>\n<p>In this step, we will create two views &#8211; <code>DefaultView<\/code> and <code>ViewScopeView<\/code> with <code>@ViewScope<\/code> annotation.<\/p>\n<p><code>DefaultView<\/code> is the one used when the web application starts.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>DefaultView.java<\/em><\/span><\/p>\n<pre class=\"brush:java; wrap-lines:false\">package jcg.zheng.demo.spring.view;\n\nimport javax.annotation.PostConstruct;\n\nimport com.vaadin.navigator.View;\nimport com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;\nimport com.vaadin.spring.annotation.SpringView;\nimport com.vaadin.ui.Label;\nimport com.vaadin.ui.VerticalLayout;\n\n@SpringView(name = DefaultView.VIEW_NAME)\npublic class DefaultView extends VerticalLayout implements View {\n\n\tprivate static final long serialVersionUID = -3903205444585313680L;\n\tpublic static final String VIEW_NAME = \"\"; \/\/default\n\n    @PostConstruct\n    void init() {\n        addComponent(new Label(\"Welcome to Vaadin-Spring Demo!!\"));\n    }\n\n    @Override\n    public void enter(ViewChangeEvent event) {\n        \/\/ This view is constructed in the init() method()\n    }\n}<\/pre>\n<p><code>ViewScopeView<\/code> is the one used when the <code>View_Scoped View<\/code> button is clicked.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>ViewScopeView.java<\/em><\/span><\/p>\n<pre class=\"brush:java; wrap-lines:false\">package jcg.zheng.demo.spring.view;\n\nimport javax.annotation.PostConstruct;\n\nimport org.springframework.beans.factory.annotation.Autowired;\n\nimport com.vaadin.navigator.View;\nimport com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;\nimport com.vaadin.spring.annotation.SpringView;\nimport com.vaadin.ui.Label;\nimport com.vaadin.ui.VerticalLayout;\n\nimport jcg.zheng.demo.spring.DemoUIScopeBean;\nimport jcg.zheng.demo.spring.DemoViewScopeBean;\n\n@SpringView(name = ViewScopeView.VIEW_NAME)\npublic class ViewScopeView extends VerticalLayout implements View {\n\n\tprivate static final long serialVersionUID = 5784972560238064106L;\n\n\tpublic static final String VIEW_NAME = \"view\";\n\t\n\t\/\/ A new instance will be created for every view instance created\n    @Autowired\n    private DemoViewScopeBean viewBean;\n    \n    \/\/ The same instance will be used by all views of the UI\n    @Autowired\n    private DemoUIScopeBean uiBean;\n    \n\n\t@PostConstruct\n\tvoid init() {\n\t\taddComponent(new Label(\"This is a view scoped view\"));\n\t\taddComponent(new Label( uiBean.getData()));\n\t\taddComponent(new Label( viewBean.getData()));\n\t}\n\n\t@Override\n\tpublic void enter(ViewChangeEvent event) {\n\t\t\/\/ This view is constructed in the init() method()\n\t}\n}\n<\/pre>\n<h4><a name=\"heading422\"><\/a>4.2.2 View with @UIScope<\/h4>\n<p>Please note that <code>@UIScope<\/code> needs to be before <code>@SpringView<\/code> because <code>@SpringView<\/code> has default attribute of <code>@ViewScope<\/code>.<\/p>\n<p>In this step, we will create two views &#8211; <code>UIScopeView<\/code> and <code>ErrorView<\/code> with <code>@UIScope<\/code> annotation.<br \/>\n<code>UIScopeview<\/code> which contains a vertical layout and displays a label from <code>DemoUIScopeBean<\/code>.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>UIScopeView.java<\/em><\/span><\/p>\n<pre class=\"brush:java; wrap-lines:false\">package jcg.zheng.demo.spring.view;\n\nimport javax.annotation.PostConstruct;\n\nimport org.springframework.beans.factory.annotation.Autowired;\n\nimport com.vaadin.navigator.View;\nimport com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;\nimport com.vaadin.spring.annotation.SpringView;\nimport com.vaadin.spring.annotation.UIScope;\nimport com.vaadin.ui.Label;\nimport com.vaadin.ui.VerticalLayout;\n\nimport jcg.zheng.demo.spring.DemoUIScopeBean;\n\n\/\/Annotation order is matter here, @UIScope is before @SpringView\n@UIScope\n@SpringView(name = UIScopeView.VIEW_NAME)\npublic class UIScopeView extends VerticalLayout implements View {\n\n\tprivate static final long serialVersionUID = -3089511061636116441L;\n\n\tpublic static final String VIEW_NAME = \"ui\";\n\n\t@Autowired\n\tprivate DemoUIScopeBean uiBean;\n\n\t@PostConstruct\n\tvoid init() {\n\t\taddComponent(new Label(\"This is a UI scoped view.\"));\n\t\taddComponent(new Label(\"uiBean says: \" + uiBean.getData()));\n\t}\n\n\t@Override\n\tpublic void enter(ViewChangeEvent event) {\n\t\t\/\/ This view is constructed in the init() method()\n\t}\n}\n<\/pre>\n<p><code>ErrorView<\/code> must be annotated with <code>@UIScope<\/code> because the SPA handles errors for the entire UI.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>ErrorView.java<\/em><\/span><\/p>\n<pre class=\"brush:java; wrap-lines:false\">package jcg.zheng.demo.spring.view;\n\nimport javax.annotation.PostConstruct;\n\nimport com.vaadin.navigator.View;\nimport com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;\nimport com.vaadin.spring.annotation.SpringView;\nimport com.vaadin.spring.annotation.UIScope;\nimport com.vaadin.ui.Label;\nimport com.vaadin.ui.VerticalLayout;\n\n@UIScope\n@SpringView(name = ErrorView.VIEW_NAME)\npublic class ErrorView extends VerticalLayout implements View {\n\n\tprivate static final long serialVersionUID = -134715779625065266L;\n\tpublic static final String VIEW_NAME = \"error\";\n\n    @PostConstruct\n    void init() {\n        addComponent(new Label(\"This is the error view - Oops!\"));\n    }\n\n    @Override\n    public void enter(ViewChangeEvent event) {\n        \/\/ This view is constructed in the init() method()\n    }\n}<\/pre>\n<h3>4.3 Spring UI<\/h3>\n<p>Vaadin Spring provides <code>@SpringUI<\/code> to instantiate UIs and to define the URL mapping for them.&nbsp;The annotated UI will automatically be placed in the&nbsp;<code>UIScope<\/code>.<\/p>\n<p>At this step, we will create <code>MainUI<\/code>, which&nbsp;contains two navigation buttons. It will switch to the correct view when the corresponding button is clicked.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>MainUI.java<\/em><\/span><\/p>\n<pre class=\"brush:java; wrap-lines:false\">package jcg.zheng.demo.spring.ui;\n\nimport com.vaadin.navigator.View;\nimport com.vaadin.navigator.ViewDisplay;\nimport com.vaadin.server.VaadinRequest;\nimport com.vaadin.spring.annotation.SpringUI;\nimport com.vaadin.spring.annotation.SpringViewDisplay;\nimport com.vaadin.ui.Button;\nimport com.vaadin.ui.Component;\nimport com.vaadin.ui.CssLayout;\nimport com.vaadin.ui.Label;\nimport com.vaadin.ui.Panel;\nimport com.vaadin.ui.UI;\nimport com.vaadin.ui.VerticalLayout;\nimport com.vaadin.ui.themes.ValoTheme;\n\nimport jcg.zheng.demo.spring.view.ErrorView;\nimport jcg.zheng.demo.spring.view.UIScopeView;\nimport jcg.zheng.demo.spring.view.ViewScopeView;\n\n@SpringUI(path = MainUI.APP_ROOT)\n@SpringViewDisplay\npublic class MainUI extends UI implements ViewDisplay {\n\n\tstatic final String APP_ROOT = \"\/vaadin-spring-demo\";\n\tprivate static final String VIEW_SCOPED_VIEW = \"View_Scoped View\";\n\tprivate static final String UI_SCOPED_VIEW = \"UI_Scoped View\";\n\tprivate static final long serialVersionUID = 4967383498113318791L;\n\tprivate Panel springViewDisplay;\n\n\t@Override\n\tprotected void init(VaadinRequest vaadinRequest) {\n\n\t\tfinal VerticalLayout root = new VerticalLayout();\n\t\troot.setSizeFull();\n\t\tsetContent(root);\n\n\t\tfinal CssLayout navigationBar = new CssLayout();\n\t\t\n\t\tnavigationBar.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);\n\t\n\t\tnavigationBar.addComponent(createNavigationButton(UI_SCOPED_VIEW, UIScopeView.VIEW_NAME));\n\t\tnavigationBar.addComponent(new Label(\" \"));\n\t\tnavigationBar.addComponent(createNavigationButton(VIEW_SCOPED_VIEW, ViewScopeView.VIEW_NAME));\n\t\n\t\troot.addComponent(navigationBar);\n\n\t\tspringViewDisplay = new Panel();\n\t\tspringViewDisplay.setSizeFull();\n\t\troot.addComponent(springViewDisplay);\n\t\troot.setExpandRatio(springViewDisplay, 1.0f);\n\n\t\tgetNavigator().setErrorView(ErrorView.class);\n\t}\n\n\tprivate Button createNavigationButton(String caption, final String viewName) {\n\t\tButton button = new Button(caption);\n\t\tbutton.addStyleName(ValoTheme.BUTTON_SMALL);\n\t\n\t\tbutton.addClickListener(event -&gt; getUI().getNavigator().navigateTo(viewName));\n\t\treturn button;\n\t}\n\n\t@Override\n\tpublic void showView(View view) {\n\t\tspringViewDisplay.setContent((Component) view);\n\t}\n\n}<\/pre>\n<h2>5. Demo Time<\/h2>\n<p>Execute&nbsp;<code>Run As Java Application<\/code>.[ulp id=&#8217;YBvYYzEYBUrADqmI&#8217;]<\/p>\n<p>Spring-boot output indicates the web application is up.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>application output<\/em><\/span><\/p>\n<pre class=\"brush:bash; wrap-lines:false\">2018-02-25 21:28:50.970  INFO 12152 --- [           main] j.z.d.s.VaadinSpringDemoApplication      : Starting VaadinSpringDemoApplication on SL2LS431841 with PID 12152 (C:\\MZheng_Java_workspace\\vaadin-spring-demo\\target\\classes started by shu.shan in C:\\MZheng_Java_workspace\\vaadin-spring-demo)\n2018-02-25 21:28:50.975  INFO 12152 --- [           main] j.z.d.s.VaadinSpringDemoApplication      : No active profile set, falling back to default profiles: default\n2018-02-25 21:28:51.110  INFO 12152 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@32464a14: startup date [Sun Feb 25 21:28:51 CST 2018]; root of context hierarchy\n2018-02-25 21:28:52.400  WARN 12152 --- [           main] o.s.c.a.ConfigurationClassPostProcessor  : Cannot enhance @Configuration bean definition 'com.vaadin.spring.VaadinConfiguration' since its singleton instance has been created too early. The typical cause is a non-static @Bean method with a BeanDefinitionRegistryPostProcessor return type: Consider declaring such methods as 'static'.\n2018-02-25 21:28:53.959  INFO 12152 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)\n2018-02-25 21:28:53.985  INFO 12152 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]\n2018-02-25 21:28:53.990  INFO 12152 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat\/8.5.27\n2018-02-25 21:28:54.231  INFO 12152 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[\/]       : Initializing Spring embedded WebApplicationContext\n2018-02-25 21:28:54.231  INFO 12152 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 3127 ms\n2018-02-25 21:28:54.471  INFO 12152 --- [ost-startStop-1] c.v.s.b.i.VaadinServletConfiguration     : Registering Vaadin servlet\n2018-02-25 21:28:54.472  INFO 12152 --- [ost-startStop-1] c.v.s.b.i.VaadinServletConfiguration     : Servlet will be mapped to URLs [\/vaadinServlet\/*, \/VAADIN\/*]\n2018-02-25 21:28:54.505  INFO 12152 --- [ost-startStop-1] c.v.s.b.i.VaadinServletConfiguration     : Setting servlet init parameters\n2018-02-25 21:28:54.506  INFO 12152 --- [ost-startStop-1] c.v.s.b.i.VaadinServletConfiguration     : Set servlet init parameter [productionMode] = [false]\n2018-02-25 21:28:54.506  INFO 12152 --- [ost-startStop-1] c.v.s.b.i.VaadinServletConfiguration     : Set servlet init parameter [resourceCacheTime] = [3600]\n2018-02-25 21:28:54.506  INFO 12152 --- [ost-startStop-1] c.v.s.b.i.VaadinServletConfiguration     : Set servlet init parameter [heartbeatInterval] = [300]\n2018-02-25 21:28:54.506  INFO 12152 --- [ost-startStop-1] c.v.s.b.i.VaadinServletConfiguration     : Set servlet init parameter [closeIdleSessions] = [false]\n2018-02-25 21:28:54.642  INFO 12152 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [\/]\n2018-02-25 21:28:54.645  INFO 12152 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'springVaadinServlet' to [\/vaadinServlet\/*, \/VAADIN\/*]\n2018-02-25 21:28:54.650  INFO 12152 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [\/*]\n2018-02-25 21:28:54.653  INFO 12152 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [\/*]\n2018-02-25 21:28:54.653  INFO 12152 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [\/*]\n2018-02-25 21:28:54.653  INFO 12152 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [\/*]\n2018-02-25 21:28:55.274  INFO 12152 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@32464a14: startup date [Sun Feb 25 21:28:51 CST 2018]; root of context hierarchy\n2018-02-25 21:28:55.411  INFO 12152 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped \"{[\/error]}\" onto public org.springframework.http.ResponseEntity&lt;java.util.Map&gt; org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)\n2018-02-25 21:28:55.413  INFO 12152 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped \"{[\/error],produces=}\" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)\n2018-02-25 21:28:55.480  INFO 12152 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [\/webjars\/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]\n2018-02-25 21:28:55.481  INFO 12152 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [\/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]\n2018-02-25 21:28:55.621  INFO 12152 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [\/**\/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]\n2018-02-25 21:28:55.681  INFO 12152 --- [           main] c.v.s.b.i.VaadinServletConfiguration     : Checking the application context for Vaadin UI mappings\n2018-02-25 21:28:55.690  INFO 12152 --- [           main] c.v.s.b.i.VaadinServletConfiguration     : Registering Vaadin servlet of type [com.vaadin.spring.server.SpringVaadinServlet]\n2018-02-25 21:28:55.703  INFO 12152 --- [           main] c.v.s.b.i.VaadinServletConfiguration     : Forwarding @SpringUI URLs from {\/vaadin-spring-demo=org.springframework.web.servlet.mvc.ServletForwardingController@22db8f4, \/vaadin-spring-demo\/=org.springframework.web.servlet.mvc.ServletForwardingController@22db8f4}\n2018-02-25 21:28:55.704  INFO 12152 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [\/vaadin-spring-demo] onto handler of type [class org.springframework.web.servlet.mvc.ServletForwardingController]\n2018-02-25 21:28:55.705  INFO 12152 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [\/vaadin-spring-demo\/] onto handler of type [class org.springframework.web.servlet.mvc.ServletForwardingController]\n2018-02-25 21:28:56.099  INFO 12152 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup\n2018-02-25 21:28:56.220  INFO 12152 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)\n2018-02-25 21:28:56.234  INFO 12152 --- [           main] j.z.d.s.VaadinSpringDemoApplication      : Started VaadinSpringDemoApplication in 5.866 seconds (JVM running for 6.483)\n2018-02-25 21:28:56.324  WARN 12152 --- [nio-8080-exec-3] c.v.s.DefaultDeploymentConfiguration     :<\/pre>\n<p>Go to&nbsp;<code>http:\/\/localhost:8080\/vaadin-spring-demo<\/code>. It&nbsp; will display &#8220;Welcome to Vaadin-Spring Demo&#8221; from the <code>DefaultView<\/code>.<\/p>\n<p><figure id=\"attachment_55725\" aria-describedby=\"caption-attachment-55725\" style=\"width: 616px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/Figure-2-SPA-default-view.jpg\"><img decoding=\"async\" class=\"size-full wp-image-55725\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/Figure-2-SPA-default-view.jpg\" alt=\"\" width=\"616\" height=\"298\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/Figure-2-SPA-default-view.jpg 616w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/Figure-2-SPA-default-view-300x145.jpg 300w\" sizes=\"(max-width: 616px) 100vw, 616px\" \/><\/a><figcaption id=\"caption-attachment-55725\" class=\"wp-caption-text\">Figure 2 SPA default view<\/figcaption><\/figure><\/p>\n<p>Click the &#8220;UI_Scoped View&#8221; button. It will display a response from <code>DemoUIScopedBean<\/code>.<\/p>\n<p><figure id=\"attachment_55726\" aria-describedby=\"caption-attachment-55726\" style=\"width: 771px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/Figure-3-SPA-UI_scoped-view.jpg\"><img decoding=\"async\" class=\"size-full wp-image-55726\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/Figure-3-SPA-UI_scoped-view.jpg\" alt=\"\" width=\"771\" height=\"243\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/Figure-3-SPA-UI_scoped-view.jpg 771w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/Figure-3-SPA-UI_scoped-view-300x95.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/Figure-3-SPA-UI_scoped-view-768x242.jpg 768w\" sizes=\"(max-width: 771px) 100vw, 771px\" \/><\/a><figcaption id=\"caption-attachment-55726\" class=\"wp-caption-text\">Figure 3 SPA UI_scoped view<\/figcaption><\/figure><\/p>\n<p>Click the &#8220;View_Scoped View&#8221; button. It will display a message from <code>DemoViewScopeBean<\/code>.<\/p>\n<p><figure id=\"attachment_55727\" aria-describedby=\"caption-attachment-55727\" style=\"width: 744px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/Figure-4-SPA-View_scoped-view.jpg\"><img decoding=\"async\" class=\"size-full wp-image-55727\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/Figure-4-SPA-View_scoped-view.jpg\" alt=\"\" width=\"744\" height=\"280\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/Figure-4-SPA-View_scoped-view.jpg 744w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/Figure-4-SPA-View_scoped-view-300x113.jpg 300w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><\/a><figcaption id=\"caption-attachment-55727\" class=\"wp-caption-text\">Figure 4 SPA View_scoped view<\/figcaption><\/figure><\/p>\n<p><strong>Note<\/strong>: <code>@UIScope<\/code> bean has same instance when clicking the button back and forth. But the <code>@ViewScope<\/code> bean has a new instance for each click.<\/p>\n<h2>6. Summary<\/h2>\n<p>In this example, we built a Vaadin Spring Boot web application via the Vaadin-Spring starter and then modified it with UI components annotated with Vaadin-Spring Add-on annotations. We demonstrated that&nbsp;Vaadin Spring Add-on provides an easier way to allow the UI and View classes to access the Spring dependency injection feature.<\/p>\n<p>You can use the Vaadin-Spring in non Spring Boot web application. I have another article with more details, please check it out <a href=\"https:\/\/examples.javacodegeeks.com\/enterprise-java\/vaadin\/vaadin-spring-security-example\/\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a>.<\/p>\n<h2>7. Download the Source Code<\/h2>\n<p>This example consists of a Spring-boot Vaadin web application.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: <a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/vaadin-spring-demo.zip\"><strong>Vaadin Spring Example<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>1. Introduction Vaadin&nbsp;is a web application framework written in Java, and is built on&nbsp;Google Web Toolkit&nbsp;from&nbsp;Vaadin Ltd. Spring Framework&nbsp;is a Java application framework that provides many useful services for building applications. Vaadin&nbsp;provides a&nbsp;Vaadin Spring add-on based on the core parts of&nbsp;vaadin4spring to make&nbsp;classes for UI and View as Spring managed beans so Spring dependency injection &hellip;<\/p>\n","protected":false},"author":140,"featured_media":33079,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1358],"tags":[1054],"class_list":["post-55653","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-vaadin","tag-spring"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Vaadin Spring Example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"1. Introduction Vaadin&nbsp;is a web application framework written in Java, and is built on&nbsp;Google Web Toolkit&nbsp;from&nbsp;Vaadin Ltd. Spring\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-spring-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Vaadin Spring Example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"1. Introduction Vaadin&nbsp;is a web application framework written in Java, and is built on&nbsp;Google Web Toolkit&nbsp;from&nbsp;Vaadin Ltd. Spring\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-spring-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2018-02-26T13:00:54+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-04-09T09:54:19+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/vaadin-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Mary Zheng\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Mary Zheng\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"15 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-spring-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-spring-example\/\"},\"author\":{\"name\":\"Mary Zheng\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/8a2034fbabcb20a9396e9819261855ae\"},\"headline\":\"Vaadin Spring Example\",\"datePublished\":\"2018-02-26T13:00:54+00:00\",\"dateModified\":\"2019-04-09T09:54:19+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-spring-example\/\"},\"wordCount\":984,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-spring-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/vaadin-logo.jpg\",\"keywords\":[\"spring\"],\"articleSection\":[\"Vaadin\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-spring-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-spring-example\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-spring-example\/\",\"name\":\"Vaadin Spring Example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-spring-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-spring-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/vaadin-logo.jpg\",\"datePublished\":\"2018-02-26T13:00:54+00:00\",\"dateModified\":\"2019-04-09T09:54:19+00:00\",\"description\":\"1. Introduction Vaadin&nbsp;is a web application framework written in Java, and is built on&nbsp;Google Web Toolkit&nbsp;from&nbsp;Vaadin Ltd. Spring\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-spring-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-spring-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-spring-example\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/vaadin-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/vaadin-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-spring-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java Development\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Vaadin\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/vaadin\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"Vaadin Spring Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/8a2034fbabcb20a9396e9819261855ae\",\"name\":\"Mary Zheng\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/11\/Mary-Zheng_avatar_1510732235-96x96.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/11\/Mary-Zheng_avatar_1510732235-96x96.jpg\",\"caption\":\"Mary Zheng\"},\"description\":\"Mary has graduated from Mechanical Engineering department at ShangHai JiaoTong University. She also holds a Master degree in Computer Science from Webster University. During her studies she has been involved with a large number of projects ranging from programming and software engineering. She works as a senior Software Engineer in the telecommunications sector where she acts as a leader and works with others to design, implement, and monitor the software solution.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/mary-zheng\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Vaadin Spring Example - Java Code Geeks","description":"1. Introduction Vaadin&nbsp;is a web application framework written in Java, and is built on&nbsp;Google Web Toolkit&nbsp;from&nbsp;Vaadin Ltd. Spring","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-spring-example\/","og_locale":"en_US","og_type":"article","og_title":"Vaadin Spring Example - Java Code Geeks","og_description":"1. Introduction Vaadin&nbsp;is a web application framework written in Java, and is built on&nbsp;Google Web Toolkit&nbsp;from&nbsp;Vaadin Ltd. Spring","og_url":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-spring-example\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2018-02-26T13:00:54+00:00","article_modified_time":"2019-04-09T09:54:19+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/vaadin-logo.jpg","type":"image\/jpeg"}],"author":"Mary Zheng","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Mary Zheng","Est. reading time":"15 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-spring-example\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-spring-example\/"},"author":{"name":"Mary Zheng","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/8a2034fbabcb20a9396e9819261855ae"},"headline":"Vaadin Spring Example","datePublished":"2018-02-26T13:00:54+00:00","dateModified":"2019-04-09T09:54:19+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-spring-example\/"},"wordCount":984,"commentCount":2,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-spring-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/vaadin-logo.jpg","keywords":["spring"],"articleSection":["Vaadin"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-spring-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-spring-example\/","url":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-spring-example\/","name":"Vaadin Spring Example - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-spring-example\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-spring-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/vaadin-logo.jpg","datePublished":"2018-02-26T13:00:54+00:00","dateModified":"2019-04-09T09:54:19+00:00","description":"1. Introduction Vaadin&nbsp;is a web application framework written in Java, and is built on&nbsp;Google Web Toolkit&nbsp;from&nbsp;Vaadin Ltd. Spring","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-spring-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-spring-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-spring-example\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/vaadin-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/01\/vaadin-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/enterprise-java\/vaadin\/vaadin-spring-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java Development","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/"},{"@type":"ListItem","position":4,"name":"Vaadin","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/vaadin\/"},{"@type":"ListItem","position":5,"name":"Vaadin Spring Example"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/8a2034fbabcb20a9396e9819261855ae","name":"Mary Zheng","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/11\/Mary-Zheng_avatar_1510732235-96x96.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/11\/Mary-Zheng_avatar_1510732235-96x96.jpg","caption":"Mary Zheng"},"description":"Mary has graduated from Mechanical Engineering department at ShangHai JiaoTong University. She also holds a Master degree in Computer Science from Webster University. During her studies she has been involved with a large number of projects ranging from programming and software engineering. She works as a senior Software Engineer in the telecommunications sector where she acts as a leader and works with others to design, implement, and monitor the software solution.","url":"https:\/\/examples.javacodegeeks.com\/author\/mary-zheng\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/55653","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/140"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=55653"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/55653\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/33079"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=55653"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=55653"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=55653"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}