sjain
sjain

Reputation: 39

Create Jar of maven spring boot project

I have following POM

<groupId>CafeWebSocket</groupId>
<artifactId>CafeWebSocket</artifactId>
<version>1.0.RELEASE</version>
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.4.2.RELEASE</version>
</parent>
<packaging>jar</packaging>
<dependencies>

     <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-websocket</artifactId>
    </dependency>

</dependencies>
<build>
    <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>1.5.6.RELEASE</version>
                <configuration>
                    <mainClass>com.cafews.Launcher</mainClass>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
    </plugins>
</build>

When I run Maven package from Maven plugin in Intellij IDEA, I see following output on Intellij console window:

"C:\Program Files\Java\jdk1.8.0_144\bin\java" -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:55051,suspend=y,server=n "-Dmaven.home=C:\Users\Saurabh Maina\apache-maven-3.5.0-bin\apache-maven-3.5.0" "-Dclassworlds.conf=C:\Users\Saurabh Maina\apache-maven-3.5.0-bin\apache-maven-3.5.0\bin\m2.conf" -Dfile.encoding=UTF-8 -classpath "C:\Users\Saurabh Maina\apache-maven-3.5.0-bin\apache-maven-3.5.0\boot\plexus-classworlds-2.5.2.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA 12.1.4\lib\idea_rt.jar" org.codehaus.classworlds.Launcher --debug --update-snapshots --fail-at-end --strict-checksums package Connected to the target VM, address: '127.0.0.1:55051', transport: 'socket' Disconnected from the target VM, address: '127.0.0.1:55051', transport: 'socket'

Process finished with exit code 1

I have maven logs at debug level, but still not clear about why JAR is not creating?

Upvotes: 2

Views: 3123

Answers (1)

sjain
sjain

Reputation: 39

Instead of running from IDE, i ran from command line . Command line output told what the error was. I am posting the pom containing plugin resource and compiler section which worked, in case it can be helpful for someone else as well.

<build>
        <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <version>1.5.6.RELEASE</version>
                    <configuration>
                        <mainClass>com.cafews.Launcher</mainClass>
                    </configuration>
                    <executions>
                        <execution>
                            <goals>
                                <goal>repackage</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <fork>true</fork>
                    <executable>C:\Program Files\Java\jdk1.8.0_144\bin\javac.exe</executable>
                </configuration>
            </plugin>
        </plugins>
        <pluginManagement>
            <plugins>
                <plugin>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>2.7</version>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

Upvotes: 1

Related Questions