mvn archetype:generate -DgroupId=com.ivandu -DartifactId=cmaimms -DarchetypeArtifactImaven-archetype-quickstart -DinteractiveMode=false
命令解释:
IDE 字符编码设置为:UTF-8, IDEA 自定义环境加入:
-Dfile.encoding=utf-8
项目 pom.xml 加入:
<properties>
<project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
properties>
项目 pom.xml 加入:
<build>
<defaultGoal>compiledefaultGoal>
build>
<properties>
<java.version>11java.version>
<maven.compiler.source>11maven.compiler.source>
<maven.compiler.target>11maven.compiler.target>
properties>
在项目 pom.xml build 节点内加入:
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-compiler-pluginartifactId>
<version>3.8.1version>
<configuration>
<verbose>trueverbose>
<fork>truefork>
<executable>D:\Tools\Java\jdk-11.0.12.7-hotspot\bin\javac.exeexecutable>
configuration>
plugin>
<properties>
<project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8project.reporting.outputEncoding>
<java.version>1.8java.version>
properties>
<profile>
<id>jdk-11id>
<activation>
<activeByDefault>trueactiveByDefault>
<jdk>11jdk>
activation>
<properties>
<project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
<maven.compiler.source>11maven.compiler.source>
<maven.compiler.target>11maven.compiler.target>
<maven.compiler.compilerVersion>11maven.compiler.compilerVersion>
properties>
profile>
<mirror>
<id>aliyunmavenid>
<mirrorOf>*mirrorOf>
<name>阿里云公共仓库name>
<url>https://maven.aliyun.com/repository/publicurl>
mirror>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-compiler-pluginartifactId>
<version>3.8.0version>
<configuration>
<source>11source>
<target>11target>
configuration>
plugin>
plugins>
<resources>
<resource>
<directory>src/main/javadirectory>
<includes>
<include>**/*.xmlinclude>
<include>**/*.propertiesinclude>
includes>
<filtering>falsefiltering>
resource>
<resource>
<directory>src/main/resourcesdirectory>
<includes>
<include>**/*.*include>
<include>**/*.propertiesinclude>
includes>
<filtering>falsefiltering>
resource>
resources>
build>
➢ compile:默认的范围,编译、测试、打包时需要。
➢ provided:表示容器会在运行时提供。
➢ runtime:表示编译时不需要,但测试和运行时需要,最终打包时会包含进来。
➢ test:只用于测试阶段。
➢ system:与provided类似,但要求该JAR是系统自带的。
11、Java执行Jar包报“jar中没有主清单属性”的解决方法:
<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.0modelVersion>
<groupId>com.cxwngroupId>
<artifactId>demoartifactId>
<version>1.0-SNAPSHOTversion>
<packaging>jarpackaging>
<name>demoname>
<url>https://maven.apache.orgurl>
<properties>
<maven.compiler.source>17maven.compiler.source>
<maven.compiler.target>17maven.compiler.target>
<project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8project.reporting.outputEncoding>
properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-maven-pluginartifactId>
<version>3.1.2version>
<configuration>
<executable>trueexecutable>
configuration>
<executions>
<execution>
<goals>
<goal>repackagegoal>
goals>
<configuration>
<attach>falseattach>
configuration>
execution>
executions>
plugin>
plugins>
build>
project>