Vaadin 10/11 (Project Base with Spring) + <packaging>war</packaging>

Hello everyone.

I’m trying to run “Project Base with Spring” generating the .war file, so I can run it on a server.

If I run the application as “Java Application”, the application works perfectly on (http: // localhost: 8080 /)

If I run the application as “Run on Server”, the application goes up normally, but the variables are not being fed by spring.

@Route
public class MainView extends VerticalLayout {

private static final long serialVersionUID = -1728241332647292539L;

   @Autowired MessageBean bean;

   public MainView () {
      Button button = new Button ("Click me", and -> Notification.show (bean.getMessage ()));
      add (button);
   }

}

I’m using Eclipse.

What is the correct way to run my application on a server (.war)?

Thank you

Hi, take a look at this: https://spring.io/guides/gs/convert-jar-to-war. You might also want to read this one: https://vaadin.com/blog/vaadin-10-and-static-resources. Hope that helps!

Alejandro Duarte:
Hi, take a look at this: https://spring.io/guides/gs/convert-jar-to-war. You might also want to read this one: https://vaadin.com/blog/vaadin-10-and-static-resources. Hope that helps!

It worked!

I made the following changes in the Application class:

@SpringBootApplication
public class Application extends SpringBootServletInitializer {

   @Override
   protected SpringApplicationBuilder configure (SpringApplicationBuilder application) {
      return application.sources (Application.class);
   }

   public static void main (String [] args) {
      SpringApplication.run (Application.class, args);
   }
}

and the following changes in the pom.xml file:

<packaging>war</packaging>

<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-tomcat</artifactId>
   <scope>provided</scope>
</dependency>

Thanks a lot for the help!

It really works! Another nice article concerning this matter:
https://thepracticaldeveloper.com/2018/08/06/how-to-deploy-a-spring-boot-war-in-wildfly-jboss/
and:
http://appsdeveloperblog.com/create-a-deployable-war-file-with-spring-boot/

Dar Mro:
It really works! Another nice article concerning this matter:
https://thepracticaldeveloper.com/2018/08/06/how-to-deploy-a-spring-boot-war-in-wildfly-jboss/

Thanks for sharing!