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

1

I'm building my first application Java Spring Boot . At this first experiment, I'm having difficulty using Git and sending it to the server. The main idea would be: I pull to a private repository, example: Bitbucket , and on my server I do, git clone. But with this, I'm having several problems, so I thought about the possibility of doing .jar and sending it by ftp. But this does not even 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 to export my Spring Boot project to the server and how to make it easy for maintenance and upgrade.

Thank you.

    
asked by anonymous 29.08.2016 / 21:31

3 answers

1

According to documentation , you must add the following plugin in your project to generate an 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
}
    
29.08.2016 / 22:11
1

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

For this you need to create a file called Manifest.mf with the following statement indicating the class with the main method ( fully qualified name ) of your 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 using Maven, as well as making it easier to manage dependencies, it will generate the already configured jar to run in this way. As a starting point, I recommend the following tutorial .

    
09.02.2017 / 17:08
0

There are several ways to deploy a Spring Boot project, the easiest way is to use fatjar generated from a mvn clean install . Check out this video .

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

Now just choose and apply the same on your server.

    
10.11.2016 / 23:10