I am simply trying to add environment variables to my project. No matter what I add to my application.properties
file, the program crashes and the pom.xml
suddenly becomes invalid and highlighted red in my IDE.
For example: If I add this to my application.properties
file:
my.test="hello"
Then the pom.xml
file becomes highlighted red with errors in my IDE and the program fails to start.
This is the error from within my pom file:
Execution default-resources of goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources failed: newPosition < 0: (-1 < 0) (org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources:default-resources:process-resources)
org.apache.maven.plugin.PluginExecutionException: Execution default-resources of goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources failed: newPosition < 0: (-1 < 0)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:148)
at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:336)
at org.eclipse.m2e.core.internal.embedder.MavenImpl.lambda$8(MavenImpl.java:1423)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:182)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:117)
at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:1422)
at org.eclipse.m2e.core.project.configurator.MojoExecutionBuildParticipant.build(MojoExecutionBuildParticipant.java:55)
at org.eclipse.m2e.core.internal.builder.MavenBuilderImpl.build(MavenBuilderImpl.java:135)
at org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:169)
at org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:1)
at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.lambda$1(MavenBuilder.java:114)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:182)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:117)
at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.lambda$0(MavenBuilder.java:105)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:182)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:156)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:103)
at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.execute(MavenBuilder.java:88)
at org.eclipse.m2e.core.internal.builder.MavenBuilder.build(MavenBuilder.java:198)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:853)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:232)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:281)
at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:334)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:337)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:389)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:410)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:160)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:251)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: java.lang.IllegalArgumentException: newPosition < 0: (-1 < 0)
at java.base/java.nio.Buffer.createPositionException(Buffer.java:318)
at java.base/java.nio.Buffer.position(Buffer.java:293)
at java.base/java.nio.ByteBuffer.position(ByteBuffer.java:1086)
at java.base/java.nio.ByteBuffer.position(ByteBuffer.java:262)
at org.apache.maven.shared.utils.io.FileUtils.copyFile(FileUtils.java:1946)
at org.apache.maven.shared.filtering.DefaultMavenFileFilter.copyFile(DefaultMavenFileFilter.java:98)
at org.apache.maven.shared.filtering.DefaultMavenResourcesFiltering.filterResources(DefaultMavenResourcesFiltering.java:262)
at org.apache.maven.plugins.resources.ResourcesMojo.execute(ResourcesMojo.java:356)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
... 30 more
CodePudding user response:
I think you have problem with encoding. Try add to your pom next property:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>