Skip to content

Commit 72896af

Browse files
authored
Merge pull request #27 from xdev-software/24-use-spring-boot-for-demo
Switched Demo to Spring boot
2 parents 5d27c53 + 5a56889 commit 72896af

File tree

6 files changed

+110
-23
lines changed

6 files changed

+110
-23
lines changed

.github/workflows/checkBuild.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,5 @@ jobs:
5959
uses: actions/upload-artifact@v3
6060
with:
6161
name: demo-files-java-${{ matrix.java }}
62-
path: ${{ env.DEMO_MAVEN_MODULE }}/target/${{ env.DEMO_MAVEN_MODULE }}.war
62+
path: ${{ env.DEMO_MAVEN_MODULE }}/target/${{ env.DEMO_MAVEN_MODULE }}.jar
6363
if-no-files-found: error

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,6 @@ ObjectStore/
109109
.idea/codeStyles/*
110110
!.idea/codeStyles/codeStyleConfig.xml
111111
!.idea/codeStyles/Project.xml
112+
113+
# Prohibit changes to managed run configuration
114+
.run/*

.run/Run Demo.run.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="Run Demo" type="Application" factoryName="Application">
3+
<option name="MAIN_CLASS_NAME" value="software.xdev.vaadin.Application" />
4+
<module name="vaadin-addon-template-demo" />
5+
<option name="WORKING_DIRECTORY" value="$MODULE_DIR$" />
6+
<extension name="coverage">
7+
<pattern>
8+
<option name="PATTERN" value="software.xdev.vaadin.*" />
9+
<option name="ENABLED" value="true" />
10+
</pattern>
11+
</extension>
12+
<method v="2">
13+
<option name="Make" enabled="true" />
14+
</method>
15+
</configuration>
16+
</component>

README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ A Vaadin Template Repo
1616

1717
## Run the Demo
1818
* Checkout the repo
19-
* Run ``mvn clean install``
20-
* Navigate into ``vaadin-addon-template-demo``
21-
* Run ``mvn jetty:run``
19+
* Run ``mvn install && mvn -f vaadin-addon-template-demo spring-boot:run``
2220
* Open http://localhost:8080
2321

2422

@@ -63,3 +61,17 @@ You should have the following things installed:
6361
* Import the project
6462
* Ensure that everything is encoded in ``UTF-8``
6563
* Ensure that the JDK/Java-Version is correct
64+
* To enable AUTOMATIC reloading/restarting while developing and running the app do this (further information in "
65+
SpringBoot-Devtools" section below; [Source](https://stackoverflow.com/q/33349456)):
66+
* ``Settings > Build, Execution, Deployment > Compiler``:<br/>
67+
Enable [``Build project automatically``](https://www.jetbrains.com/help/idea/compiling-applications.html#auto-build)
68+
* ``Settings > Advanced Settings``:<br/>
69+
Enable [``Allow auto-make to start even if developed application is currently running``](https://www.jetbrains.com/help/idea/advanced-settings.html#advanced_compiler)
70+
* To launch the Demo execute the predefined (launch) configuration ``Run Demo``
71+
72+
#### [SpringBoot-Developer-Tools](https://docs.spring.io/spring-boot/docs/current/reference/html/using.html#using.devtools)
73+
... should automatically be enabled.<br/>
74+
If you are changing a file and build the project, parts of the app get restarted.<br/>
75+
Bigger changes may require a complete restart.
76+
* [Vaadin automatically reloads the UI on each restart](https://vaadin.com/docs/latest/configuration/live-reload/spring-boot).<br/>
77+
You can control this behavior with the ``vaadin.devmode.liveReload.enabled`` property (default: ``true``).<br/>

vaadin-addon-template-demo/pom.xml

Lines changed: 53 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<groupId>com.xdev-software</groupId>
88
<artifactId>vaadin-addon-template-demo</artifactId>
99
<version>1.0.0-SNAPSHOT</version>
10-
<packaging>war</packaging>
10+
<packaging>jar</packaging>
1111

1212
<inceptionYear>2022</inceptionYear>
1313

@@ -32,10 +32,13 @@
3232
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3333
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
3434

35+
<mainClass>software.xdev.vaadin.Application</mainClass>
36+
3537
<!-- Dependency-Versions -->
3638
<vaadin.version>23.3.4</vaadin.version>
37-
</properties>
3839

40+
<org.springframework.boot.version>2.7.7</org.springframework.boot.version>
41+
</properties>
3942

4043
<dependencyManagement>
4144
<dependencies>
@@ -46,6 +49,17 @@
4649
<scope>import</scope>
4750
<version>${vaadin.version}</version>
4851
</dependency>
52+
53+
<!-- Spring Boot -->
54+
<!-- This bom provides versions for ~500 dependencies -->
55+
<!-- Nearly at the end so that it doesn't accidentally overwrite other versions -->
56+
<dependency>
57+
<groupId>org.springframework.boot</groupId>
58+
<artifactId>spring-boot-dependencies</artifactId>
59+
<version>${org.springframework.boot.version}</version>
60+
<type>pom</type>
61+
<scope>import</scope>
62+
</dependency>
4963
</dependencies>
5064
</dependencyManagement>
5165

@@ -63,21 +77,32 @@
6377
<groupId>org.slf4j</groupId>
6478
<artifactId>slf4j-simple</artifactId>
6579
</dependency>
80+
<!-- Spring -->
81+
<dependency>
82+
<groupId>com.vaadin</groupId>
83+
<artifactId>vaadin-spring-boot-starter</artifactId>
84+
</dependency>
85+
<dependency>
86+
<groupId>org.springframework.boot</groupId>
87+
<artifactId>spring-boot-devtools</artifactId>
88+
<optional>true</optional>
89+
</dependency>
6690
</dependencies>
6791

6892
<build>
6993
<finalName>${project.artifactId}</finalName>
94+
95+
<pluginManagement>
96+
<plugins>
97+
<plugin>
98+
<groupId>org.springframework.boot</groupId>
99+
<artifactId>spring-boot-maven-plugin</artifactId>
100+
<version>${org.springframework.boot.version}</version>
101+
</plugin>
102+
</plugins>
103+
</pluginManagement>
70104

71105
<plugins>
72-
<!-- Jetty plugin for easy testing without a server -->
73-
<plugin>
74-
<groupId>org.eclipse.jetty</groupId>
75-
<artifactId>jetty-maven-plugin</artifactId>
76-
<version>10.0.13</version>
77-
<configuration>
78-
<scan>1</scan>
79-
</configuration>
80-
</plugin>
81106
<plugin>
82107
<groupId>com.vaadin</groupId>
83108
<artifactId>vaadin-maven-plugin</artifactId>
@@ -101,14 +126,6 @@
101126
</compilerArgs>
102127
</configuration>
103128
</plugin>
104-
<plugin>
105-
<groupId>org.apache.maven.plugins</groupId>
106-
<artifactId>maven-war-plugin</artifactId>
107-
<version>3.3.2</version>
108-
<configuration>
109-
<failOnMissingWebXml>false</failOnMissingWebXml>
110-
</configuration>
111-
</plugin>
112129
</plugins>
113130
</build>
114131

@@ -140,6 +157,23 @@
140157
</execution>
141158
</executions>
142159
</plugin>
160+
<plugin>
161+
<groupId>org.springframework.boot</groupId>
162+
<artifactId>spring-boot-maven-plugin</artifactId>
163+
<configuration>
164+
<mainClass>${mainClass}</mainClass>
165+
<fork>true</fork>
166+
</configuration>
167+
<executions>
168+
<execution>
169+
<id>repackage</id>
170+
<goals>
171+
<goal>repackage</goal>
172+
</goals>
173+
<phase>package</phase>
174+
</execution>
175+
</executions>
176+
</plugin>
143177
</plugins>
144178
</build>
145179
</profile>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package software.xdev.vaadin;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
6+
7+
import com.vaadin.flow.component.page.AppShellConfigurator;
8+
import com.vaadin.flow.component.page.Push;
9+
import com.vaadin.flow.spring.annotation.EnableVaadin;
10+
11+
12+
@SpringBootApplication
13+
@EnableVaadin
14+
@Push
15+
public class Application extends SpringBootServletInitializer implements AppShellConfigurator
16+
{
17+
public static void main(final String[] args)
18+
{
19+
SpringApplication.run(Application.class, args);
20+
}
21+
}
22+

0 commit comments

Comments
 (0)