When building my service project with jib command mvn clean compile jib:build it's give the following error:
Failed to execute goal com.google.cloud.tools:jib-maven-plugin:1.0.2:build (build-image-and-tag-image) on project my-service: Multiple valid main classes were found: com.myservice.MyServiceApplication, io.swagger.Swagger2SpringBoot, perhaps you should add a
mainClass
configuration to jib-maven-plugin -> [Help 1]
However I have set the main classes for spring-boot
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.myservice.MyServiceApplication</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
It's still doesn't work.
I've tried to add it to the jib config to:
<plugins>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<configuration>
<container>
<mainClass>com.myservice.MyServiceApplication</mainClass>
</container>
</configuration>
<executions>
<execution>
<id>build-image-and-tag-image</id>
<phase>package</phase>
<goals>
<goal>dockerBuild</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
It's still doesn't work. Any other way to force jib to ignore the other class and use com.myservice.MyServiceApplication instead.
Note: mvn clean install work fine and I have no problem using it has a stand alone spring boot app.