creating a jar file in spring boot that is using command line runners

I have an application that is using command-line runners from spring-boot. When I want to build a jar package through

.mvnw package
.mvnw clean install

It just start the application instead of building the .jar as expected. I have below plugin

<plugins>
    <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <version>2.4.0</version>
    </plugin>
</plugins>

The code is working fine but i need to use a jar file. How can i achieve that?

Answer

if you need run your test task, you need run “mvn clean package “, else run “mvn clean package -Dmaven.test.skip=true”, jar file in your project root path ‘target’