What is the best way to send my Spring Boot project to the server?

Asked

Viewed 2,409 times

2

I’m building my first application Java Spring Boot. In this first experiment, I’m having trouble using Git and sending it to the server. The main idea would be: I pull into a private repository, example: Bitbucket, and on my server do, the git clone. But with this, I’m having several problems, so I thought about the possibility of doing . jar and send it by ftp. But even that doesn’t work on the server when I do java -jar projeto.jar, i have the following errors:

nenhum atributo de manifesto principal em projeto.jar

I would like to know from other developers' experience, what is the best practice of exporting my Spring Boot project to the server and how to make it easy for maintenance and upgrade.

Grateful.

  • Did any answers help you? Some detail was missing?

3 answers

1

According to the documentation, you must add the following plugin to your project to generate a executable jar.

If you use Maven

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <executable>true</executable>
            </configuration>
        </plugin>
    </plugins>
</build>

If you use Gradle

apply plugin: 'spring-boot'

springBoot {
    executable = true
}

1

Running the application with java -jar project.jar is really a very simple option. This error is occurring because you did not generate the jar in the correct way.

For this it is necessary to create a file called Manifest.mf with the following statement indicating the class with the main method (Fully Qualified name) of its application:

Main-Class: br.com.projeto.Test

And then generate the jar by passing this file:

jar -cfm projeto.jar Manifest.mf br.com.projeto

In order to simplify your project, I suggest the use of Maven, because in addition to facilitating the management of dependencies, will generate the jar already configured to run in this way. As a starting point, I recommend the following tutorial.

1

There are several ways to deploy a Spring Boot project, the easiest way is by using the billow generated from a mvn clean install. Look at this video.

Another alternative is to convert the JAR into WAR (click here).

Now just choose and apply the same on your server.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.