dcsaorg / DCSA-BKG

0 stars 1 forks source link

Cannot run : Unable to find a suitable main class, please add a 'mainClass' property #124

Closed Sigurdur42 closed 2 years ago

Sigurdur42 commented 2 years ago

Hi, I am getting this error now when running mvn spring-boot:run -Dspring-boot.run.arguments="--db_hostname=localhost:5432":

[INFO] Scanning for projects...
[INFO]
[INFO] -------------------------< org.dcsa:dcsa_core >-------------------------
[INFO] Building DCSA-Core 0.8.33-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] >>> spring-boot-maven-plugin:2.6.6:run (default-cli) > test-compile @ dcsa_core >>>
[INFO]
[INFO] --- maven-enforcer-plugin:3.0.0:enforce (enforce) @ dcsa_core ---
Downloading from central: https://repo1.maven.org/maven2/org/dcsa/dcsa_core/0.8.33-SNAPSHOT/maven-metadata.xml
Downloading from github: https://maven.pkg.github.com/dcsaorg/DCSA-Core/org/dcsa/dcsa_core/0.8.33-SNAPSHOT/maven-metadata.xml
Downloaded from github: https://maven.pkg.github.com/dcsaorg/DCSA-Core/org/dcsa/dcsa_core/0.8.33-SNAPSHOT/maven-metadata.xml (1.6 kB at 1.3 kB/s)
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ dcsa_core ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] skip non existing resourceDirectory C:\sourcen\github\DCSA-Core\src\main\resources
[INFO] skip non existing resourceDirectory C:\sourcen\github\DCSA-Core\src\main\resources
[INFO]
[INFO] --- flatten-maven-plugin:1.1.0:flatten (flatten) @ dcsa_core ---
[INFO] Generating flattened POM of project org.dcsa:dcsa_core:jar:0.8.33-SNAPSHOT...
[INFO]
[INFO] --- maven-compiler-plugin:3.10.1:compile (default-compile) @ dcsa_core ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:testResources (default-testResources) @ dcsa_core ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] skip non existing resourceDirectory C:\sourcen\github\DCSA-Core\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.10.1:testCompile (default-testCompile) @ dcsa_core ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] <<< spring-boot-maven-plugin:2.6.6:run (default-cli) < test-compile @ dcsa_core <<<
[INFO]
[INFO]
[INFO] --- spring-boot-maven-plugin:2.6.6:run (default-cli) @ dcsa_core ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  5.532 s
[INFO] Finished at: 2022-05-13T10:13:12+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.6.6:run (default-cli) on project dcsa_core: Unable to find a suitable main class, please add a 'mainClass' property -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Is there a configuration I need to add?

pimg commented 2 years ago

Hi @Sigurdur42 what environment are you running this command, Windows Powershell? or CMD or another environment?

when running in Powershell the - needs to be escaped with a backtick. So in Powershell the command to run the application is: mvn spring-boot:run `-Dspring-boot.run.arguments="--db_hostname=localhost:5432"

Sigurdur42 commented 2 years ago

Hi @pimg, I am using the command line now. Maybe I do use the wrong java version?

set JAVA_HOME
JAVA_HOME=C:\Program Files\Java\jdk-17.0.3.1 
pimg commented 2 years ago

Hi, you are using the correct JDK version.

Just for clarity this command works in Windows CMD: mvn spring-boot:run -Dspring-boot.run.arguments="--db_hostname=localhost:5432"

This command works in Windows PowerShell: mvn spring-boot:run `-Dspring-boot.run.arguments="--db_hostname=localhost:5432"

Sigurdur42 commented 2 years ago

Hi, I just tried this again in windows cmd line: Just for clarity this command works in Windows CMD: mvn spring-boot:run -Dspring-boot.run.arguments="--db_hostname=localhost:5432"

Same error as before :(

pimg commented 2 years ago

Hi, in your original message (top of this thread) it mentioned:

Building DCSA-Core 0.8.33-SNAPSHOT

However this command: mvn spring-boot:run -Dspring-boot.run.arguments="--db_hostname=localhost:5432" needs to be issued in the BKG repository, so the output looks roughly like this:

C:\Users\User\workspace\dcsa\DCSA-BKG>mvn spring-boot:run -Dspring-boot.run.arguments="--db_hostname=localhost:5432"
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------------< org.dcsa:dcsa_bkg >--------------------------
[INFO] Building DCSA-BKG 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] >>> spring-boot-maven-plugin:2.6.6:run (default-cli) > test-compile @ dcsa_bkg >>>
[INFO]
[INFO] --- maven-enforcer-plugin:3.0.0:enforce (enforce) @ dcsa_bkg ---
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ dcsa_bkg ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- flatten-maven-plugin:1.1.0:flatten (flatten) @ dcsa_bkg ---
[INFO] Generating flattened POM of project org.dcsa:dcsa_bkg:jar:0.0.1-SNAPSHOT...
[INFO]
[INFO] --- maven-compiler-plugin:3.10.1:compile (default-compile) @ dcsa_bkg ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:testResources (default-testResources) @ dcsa_bkg ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 9 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.10.1:testCompile (default-testCompile) @ dcsa_bkg ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] <<< spring-boot-maven-plugin:2.6.6:run (default-cli) < test-compile @ dcsa_bkg <<<
[INFO]
[INFO]
[INFO] --- spring-boot-maven-plugin:2.6.6:run (default-cli) @ dcsa_bkg ---
[INFO] Attaching agents: []

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.6.6)

2022-05-16 10:31:19.363  INFO 73480 --- [           main] org.dcsa.bkg.Application                 : Starting Application using Java 17.0.2 on  with PID 73480 (C:\Users\User\workspace\dcsa\DCSA-BKG\target\classes started by User in C:\Users\User\workspace\dcsa\DCSA-BKG)
2022-05-16 10:31:19.365  INFO 73480 --- [           main] org.dcsa.bkg.Application                 : The following 1 profile is active: "dev"
2022-05-16 10:31:19.809  INFO 73480 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data R2DBC repositories in DEFAULT mode.
2022-05-16 10:31:19.997  INFO 73480 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 188 ms. Found 51 R2DBC repository interfaces.
2022-05-16 10:31:21.248  INFO 73480 --- [           main] ctiveUserDetailsServiceAutoConfiguration :

Using generated security password: f8144aa1-54c6-4a5f-b56e-c01cd9be05ad

2022-05-16 10:31:21.314  INFO 73480 --- [           main] o.d.c.c.DCSACoreConfiguration            : Enabled support for Proxy headers (X-Forwarded-*, etc.) from *any* IP. Use dcsa.supportProxyHeader=[true|false] to change this
2022-05-16 10:31:21.464  INFO 73480 --- [           main] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 1 endpoint(s) beneath base path '/actuator'
2022-05-16 10:31:21.671  INFO 73480 --- [           main] o.s.b.web.embedded.netty.NettyWebServer  : Netty started on port 9090
2022-05-16 10:31:21.680  INFO 73480 --- [           main] org.dcsa.bkg.Application                 : Started Application in 2.62 seconds (JVM running for 2.888)
2022-05-16 10:31:21.681  INFO 73480 --- [           main] org.dcsa.core.security.SecurityConfig    : You are currently running : dev : security is disabled for this profile. Please use `prod` profile to activate security.
2022-05-16 10:31:21.683  INFO 73480 --- [           main] o.d.c.e.s.impl.MessageSignatureHandler   : Enabled pending event notification service.  Use dcsa.pendingEventService.enabled=true to activate it
2022-05-16 10:31:21.683  INFO 73480 --- [           main] o.d.c.e.s.impl.MessageSignatureHandler   : Customize delivery via dcsa.pendingEventService.subscriptionHandler.<option>. Valid <option> include:
2022-05-16 10:31:21.684  INFO 73480 --- [           main] o.d.c.e.s.impl.MessageSignatureHandler   :   connectionTimeout, readTimeout, writeTimeout, followRedirects, and enableTLSValidation
2022-05-16 10:31:21.684  INFO 73480 --- [           main] o.d.c.e.s.impl.MessageSignatureHandler   : TLS validation is enabled for subscription delivery. HTTPS callback URLS must all present valid TLS certificates.
Sigurdur42 commented 2 years ago

OMG - this is so stupid :)

You are correct - now it works. Thx for the support

pimg commented 2 years ago

You're welcome