Getting Started with Vaadin Spring and Spring Boot!

Hi,

I’m trying Vaadin with Spring Boot, and created a project using http://start.spring.io, and followed the steps depicted there!

After loading it into IntelliJ 15.0.3 and running it I get the following error:

[code]

at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]

at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]

at org.springframework.boot.SpringApplication.run(SpringApplication.java:1191) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]

at org.springframework.boot.SpringApplication.run(SpringApplication.java:1180) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]

at com.example.DemoApplication.main(DemoApplication.java:10) [classes/:na]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_95]

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_95]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_95]

at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_95]

at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) [idea_rt.jar:na]

Caused by: java.lang.IllegalArgumentException: @ConditionalOnMissingBean annotations must specify at least one bean (type, name or annotation)
at org.springframework.util.Assert.isTrue(Assert.java:68) ~[spring-core-4.2.5.RELEASE.jar:4.2.5.RELEASE]


[/code]Anybody any idea why this error occurs, and how to tackle it!

Regards,
Gerard

Hi,

Are you able to attach the project here?

Hi,

It’s a very basic application, you find it attached! Thanks for trying to help!

By the way when I run the application by entering
mvn spring-boot:run
at the command line it runs without problems and can access it via http://localhost:8080/

Regards,
Gerard

23429.java (1.15 KB)
23430.java (615 Bytes)
23431.java (2.48 KB)
23432.xml (2.87 KB)
23433.java (299 Bytes)

Thanks for the files, but… any chance that you can attach the whole project (as a ZIP file) so that I can compile it and run it?

Hi,

Sorry, of course! You’ll find it attached!

Regards,
Gerard[quote=Alejandro Duarte]
Thanks for the files, but… any chance that you can attach the whole project (as a ZIP file) so that I can compile it and run it?
[/quote]
23434.zip (96.7 KB)

Hi,

Sorry, the ZIP file is incorrect; have attached a new one for you!

Regards,
Gerard

23435.zip (98.6 KB)

Hi, thanks for the file.

Try removing the
spring-boot-starter-tomcat
dependency from your
pom.xml
. You can also remove the
ServletInitializer
class.

Hi,

Did remove the dependency and th ServletInitializer class; but still the same error!

Regards,
Gerard

It worked for me. Did you run
mvn clean install
?

Hi,

Yes this works but also when the dependency, and the ServletInitializer class are there!

But when I use the
Run ‘demo’
from the menubar of IntelliJ IDEA 15.0.4 I get the error complaining about a missing bean!

Regards,
Gerard

Hi, it works for me when using
Run ‘demo’
. If I keep the
spring-boot-starter-tomcat
dependency, then I get the error. So, I would suggest to remove that dependency, run
mvn clean install
, and then,
Run ‘demo’
.

Hi Alejandro,

I still have the ServletInitializer class, and removed the dependency!
Now it works, but I don’t understand what is going on! Could you explain this to me?

Regards,
Gerard

It’s actually quite simple.

The
spring-boot-starter-tomcat
dependency is included by default when you inherit
spring-boot-starter-parent
.

The
pom.xml
you attached, explicitly included the
spring-boot-starter-tomcat
dependency with a slight difference: You specified the
provided
scope. This scope means that the dependency is to be provided by the JDK or server. So, you can compile of course, but you will run into errors when starting the application as this dependency won’t be in the classpath at run time.

Moreover, your application should also run if you keep the
spring-boot-starter-tomcat
dependency but remove the
provided
part.

Hope that helps clarifying.

Hi Alejandro,

Thanks for your clear answer!

I think I have to dig a bit deeper into spring-boot to be able to better understand what is going on behind the scenes, enabling me to use it more effectively in combination with Vaadin.

Any suggestions are very much welcomed!

Thanks for all your help!

Regards,
Gerard