John Van den Berg
John Van den Berg

Reputation: 111

Deploying/hosting Spring Boot application

I have recently finished a simple spring boot application using the INTELLIJ IDE. The applications runs locally as a spring application as well as in Tomcat.

For my next step I would like to be able to host the application online but every attempt i've made seems to fail it doesn't even run on Xampp's Tomcat.

Heres my hierachy:

application.properties:

spring.datasource.driver-class-name = com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://xxx.xxx.xxx.xxx:3306/db_digitrainer
spring.datasource.username=test
spring.datasource.password=test

server.context-path=/digitrainer

management.context-path=/manage

Application.java:

@SpringBootApplication
@Configuration
@EnableAutoConfiguration
@EnableWebMvc
@ComponentScan
public class Application extends SpringBootServletInitializer {

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

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

I have been unable to find any clear information on how to do this so I would love to know if I am doing something wrong and also if spring boot is the approach for developing a rest API.

Upvotes: 5

Views: 5838

Answers (2)

John Van den Berg
John Van den Berg

Reputation: 111

It seems my problem was a typical beginner issue. When building my project I did end up with two WAR files in my build directory which I tried to deploy. Because these WAR files were not packaged yet they obviously didn't work.

In the end all I had forgotten to do was open cmd, navigate to my project directory and use maven's "mvn package" command. After that everything worked.

Upvotes: 0

Sanjay
Sanjay

Reputation: 8965

I find deploying at Pivotal Could Foundry seamless. For that, this guide works well when using STS. When using some other IDE, or for the elaborated steps, this blog post could be useful. Yes, I find Spring Boot quite good for developing a REST API, and am almost nearing the end of developing the first version of an open source project for that purpose.

Upvotes: 1

Related Questions