最近我想在 IntelliJ 中创建 maven 项目时更改默认的 maven pom 文件。所以我进入设置并编辑了模板。
但是因为我在这里,所以效果不是很好。
每次我尝试创建一个新的 maven 项目(并使用模板)时,我都会收到以下错误:
命名捕获组缺少尾随 '}'
所以我猜我的模板中存在格式问题,但我找不到它的来源。
这是我所做的:
<?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>
#if (${HAS_PARENT})
<parent>
<groupId>${PARENT_GROUP_ID}</groupId>
<artifactId>${PARENT_ARTIFACT_ID}</artifactId>
<version>${PARENT_VERSION}</version>
#if (${HAS_RELATIVE_PATH})
<relativePath>${PARENT_RELATIVE_PATH}</relativePath>
#end
</parent>
#end
<groupId>${GROUP_ID}</groupId>
<artifactId>${ARTIFACT_ID}</artifactId>
<version>${VERSION}</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>9</java.version>
<main.class><!-- TODO --></main.class>
</properties>
<packaging>jar</packaging>
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ftp</artifactId>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>jar-with-dependencies</shadedClassifierName>
<finalName>${DS}{project.artifactId}</finalName>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>${DS}{main.class}</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>${DS}{java.version}</source>
<target>${DS}{java.version}</target>
<release>${DS}{java.version}</release>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<copy file="${DS}{basedir}/target/${DS}{project.artifactId}.jar" tofile="${DS}{copy.build.path}/${DS}{project.artifactId}.jar"/>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<distributionManagement>
<repository>
<id>mrcraftcod.write</id>
<url>${DS}{mrcraftcod.write.url}</url>
</repository>
</distributionManagement>
<repositories>
</repositories>
<dependencies>
</dependencies>
</project>
感谢您的帮助。