maciejwalkowiak / just

Magical πŸͺ„ command line toolkit for developing πŸƒ Spring Boot apps
312 stars 6 forks source link

How to pass "-Dfile.encoding=UTF-8" argument #27

Open gantoin opened 1 year ago

gantoin commented 1 year ago

I tried with different syntaxes referring to the docs: https://just.maciejwalkowiak.com/docs/usage/just-run/

I want to run as similar to this Spring Boot config (using Spring 2.7.5):

screenshot

just run -Dspring-boot-run-arguments=--file.encoding=UTF-8
just run -Dspring-boot-run-arguments=-Dfile.encoding=UTF-8
just run -Drun.arguments=-Dfile.encoding=UTF-8
just run -Drun.arguments="-Xdebug -Dfile.encoding=UTF-8"
just run -Drun.jvmArguments="-Xdebug -Dfile.encoding=UTF-8"
just run -Drun.jvmArguments="-Dfile.encoding=UTF-8"
just run -Dfile.encoding=UTF-8
just run -Dspring-boot.run.jvmArguments="-Dfile.encoding=UTF-8"
just run -Dspring-boot.run.jvmArguments=""-Dfile.encoding=UTF-8"

Still have an error on boot:

java.lang.IllegalStateException: The Java Virtual Machine has not been configured to use the desired default character encoding (UTF-8).

If someone knows how to run it with just, I'm listening 🍻

maciejwalkowiak commented 1 year ago

There seems to be a bug with passing parameters with "-D". As a workaround, create in your project root a file just.properties with content:

just.run.extra-args=-Dspring-boot.run.jvmArguments="-Dfile.encoding=UTF-8"

Now just run with just run. Let me know please if it helps!

gantoin commented 1 year ago

Thanks for your answer, unfortunately, it doesn’t fix my problem 😿

maciejwalkowiak commented 1 year ago

@gantoin 3 more questions:

gantoin commented 1 year ago

Hi, @maciejwalkowiak πŸ‘‹ I fixed it by answering your questions :

So, I found a way to fix my problem; force the JVM argument in the spring boot plugin in my pom.xml:

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <jvmArguments>-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5198 -Dfile.encoding=UTF-8</jvmArguments>
        <wait>500</wait>
        <maxAttempts>240</maxAttempts>
    </configuration>
</plugin>

Now I can run my app correctly with just run or ./mvnw spring-boot:run πŸŽ‰ Thanks for your responsiveness, and your work in general on just tool ❀️

maciejwalkowiak commented 1 year ago

Thanks for quick answer! This means that something is off with passing it with just.run.extra-args. I will investigate!

lucasleon2107 commented 1 year ago

Hi @maciejwalkowiak, is passing -D arguments for environment variables fixed? Also, how should I send multiple env vars to the run command?