Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

  • src
  • ----java
  • ---------com.jcode
  • ---------------TestController.java
  • ---------------Application.java
  • ----resources
  • ---------application.properties

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.

like image 288
John Van den Berg Avatar asked Nov 10 '22 04:11

John Van den Berg


1 Answers

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.

like image 169
Sanjay Avatar answered Nov 15 '22 06:11

Sanjay