[ad_1]
Basically, I added code to an already existing REST API (java
, Springboot
). when I run it on Intellij
there’s no problem and I can use it as intended.
The thing is that I want to test it on a Docker container.
I builded the .jar
of the project by using Build->Build Artifact->project_name.jar->Build
and when I try to docker-compose up
I get several problems.
The folder I use contains : a docker-compose.yml
, a Dockerfile
, and the .jar
I know the first two files are ok as I used them to run a small test project and had no errors.
The first problem I got when building the container is :no main manifest attribute, in /project_name.jar
My MANIFEST.MF
look like this in my IDE :
Manifest-Version: 1.0
Main-Class: com.project.project_name.adapters.api.Application
but in my .jar
artifact look like this :
Manifest-Version: 1.0
Implementation-Title: spring-beans
Automatic-Module-Name: spring.beans
Implementation-Version: 5.2.3.RELEASE
Created-By: 1.8.0_232 (Oracle Corporation)
So my first question is why is it different and why is it deleting the part with the Main Class
? And of course how to solve this problem ?
As a temporary solution, I added the Main Class
in the MANIFEST.MF
by hand in my .jar
By doing so, I get a MANIFEST.MF
that look like this :
Manifest-Version: 1.0
Main-Class: com.project.project_name.adapters.api.Application
Implementation-Title: spring-beans
Automatic-Module-Name: spring.beans
Implementation-Version: 5.2.3.RELEASE
Created-By: 1.8.0_232 (Oracle Corporation)
When I try to docker-compose up
once again, I get this error :
java.lang.IllegalArgumentException: No auto configuration classes found in META -INF/spring.factories. If you are using a custom packaging, make sure that file is correct.
I’m not really a pro in Springboot
, and that’s an ex-coworker who did the first part of the project, but I’m pretty sure it uses custom packaging.
the file spring.factories
look like this :
org.springframework.beans.BeanInfoFactory=org.springframework.beans.ExtendedBeanInfoFactory
and I don’t know if this is supposed to be correct or not.
I’m clearly missing something but I don’t really know what, even after looking here for similar problem and potential solution, but nothing did the trick.
Just in case here’s my pom.xml :
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.piroux</groupId>
<artifactId>phoenixrh-backend</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>10</source>
<target>10</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.piroux.phoenixrhbackend.adapters.api.Application</mainClass>
</configuration>
<version>2.1.4.RELEASE</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.4.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>2.2.4.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>de.bechte.junit</groupId>
<artifactId>junit-hierarchicalcontextrunner</artifactId>
<version>4.12.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.45</version>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>1.14.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mysql</artifactId>
<version>1.14.3</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Not sure if any other information is needed, but if so just tell me.
[ad_2]