Paulo_Henrique
(Paulo Henrique Passella)
1
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
alejandro.du
(Alejandro Duarte)
2
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!
Dar2
(Dar Mro)
4