Search code examples
javaspring-bootdockermaven-plugin

Application build is successful but getting error: 'no main manifest attribute, in app.jar' while running the image


I am trying to deploy my spring boot application on a docker. I have created a docker file as follows.

FROM registry.gitlab.com/client/micro/micro-services/baseimage/database-baseimage/tmo-main:database-baseimage-1.0.1f28a87b

ADD  ./target/*.jar app.jar
ENV TZ=America/Los_Angeles
ENTRYPOINT ["java","-XX:+UnlockExperimentalVMOptions","-XX:+UseContainerSupport","-XX:MaxRAMFraction=1","-XX:+UseG1GC","-jar","app.jar"]
EXPOSE 8080

The docker file builds fine but when I run the image it throws the following error:

OpenJDK 64-Bit Server VM warning: Option MaxRAMFraction was deprecated in version 10.0 and will likely be removed in a future release.
no main manifest attribute, in app.jar

Please note that my application runs on JDK 11, maven build and already added dependency for spring-boot-maven-plugin. I couldn't find a proper solution for this query on internet. Hence requesting for the reason for this error and solution.


Solution

  • Resolved this issue by setting execution goals as 'repackage' in spring-boot-maven-plugin.

    <plugin> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-maven-plugin</artifactId> 
     <executions> 
      <execution> 
       <goals> 
        <goal>repackage</goal> 
       </goals> 
      </execution> 
     </executions> 
    </plugin>