1
resposta

Aparece mensagem de erro quando tentar rodar o comando Docker Run

Olá, Tentei de rodar o docker run e apareceu o mensagem de erro, veja: Já executei mvn package antes de executar -> mvn clean package -DGOSPORTS_PROFILE_ACTIVE=test

jeisonpereira@go-sports-backend % docker build -t go-sports .
[+] Building 1.0s (8/8) FINISHED                                                                                                                                                                                                        
 => [internal] load build definition from Dockerfile                                                                                                                                                                               0.0s
 => => transferring dockerfile: 263B                                                                                                                                                                                               0.0s
 => [internal] load .dockerignore                                                                                                                                                                                                  0.0s
 => => transferring context: 2B                                                                                                                                                                                                    0.0s
 => [internal] load metadata for docker.io/library/openjdk:8-jdk-alpine                                                                                                                                                     
 => [internal] load build context                                                                                                                                                                                                  0.0s
 => => transferring context: 70B                                                                                                                                                                                                   0.0s
 => [1/3] FROM docker.io/library/openjdk:8-jdk-alpine@sha256:94792824df2df33402f201713f932b58cb9de94a0cd524164a0f2283343547b3                         
 => CACHED [2/3] RUN addgroup -S spring && adduser -S spring -G spring                                                                                                                                               
 => CACHED [3/3] COPY target/*.jar app.jar                                                                                                                                                                                         0.0s
 => exporting to image                                                                                                                                                                                                             0.0s
 => => exporting layers                                                                                                                                                                                                            0.0s
 => => writing image sha256:1edcaba80a4b5f6e6e81d386d962af0c8ca3d4cb5b84a6ef9cf39be6e01964f0                                                                                       
 => => naming to docker.io/library/go-sports                                                                                                                                                                                       0.0s
Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them
jeisonpereira@go-sports-backend % docker run -p 8080:8080 -e GOSPORTS_DATABASE_URL='jdbc:h2:mem:go-sports' -e GOSPORTS_DATABASE_USERNAME='admin' -e GOSPORTS_DATABASE_PASSWORD='admin' -e GOSPORTS_JWT_SECRET='@Bcd$P-12345' -e GOSPORTS_PROFILE_ACTIVE='prod' -e GOSPORTS_JWT_EXPIRATION=86400000 go-sports
Exception in thread "main" java.lang.ClassNotFoundException: GoSportsBackendApplication
        at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:151)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:348)
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:46)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:108)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)

Veja o repositório do branch seguinte: https://github.com/jsnpereira/go-sports-backend/pull/11

1 resposta

Oi Lucas,

O erro: Exception in thread "main" java.lang.ClassNotFoundException: GoSportsBackendApplication

No seu pom.xml tem essa linha:

<mainClass>GoSportsBackendApplication</mainClass>

Mas o nome da classe está sem o pacote e por isso deu a exception.