工具与资源核心
帮忙开发者更加高效的工作,提供围绕开发者全生命周期的工具与资源
https://developer.aliyun.com/...

插件篇

1. Maven中指定Java的编译版本和源文件编码方式

Maven默认编译版本是JDK1.5,在很多时候,发现有些代码报错,又找不到起因,很有可能是没有配置JDK版本。就如有一次我遇到的问题:定义全局异样解决类继承HandlerInterceptorAdapter时候,preHandle办法下面有@Override就始终报错,点开HandlerInterceptorAdapter源码,显著是有这个办法,起初发现JDK版本的问题,按如下办法设置好后,谬误解决了。

1. 1 第一种形式

在我的项目的pom.xml文件中指定,然而此办法只对该我的项目无效,如下图红框所示,设置为JDK1.8。

<build>        <plugins>            <!-- 设置JDK版本 -->            <plugin>                <groupId>org.apache.maven.plugins</groupId>                <artifactId>maven-compiler-plugin</artifactId>                <version>3.1</version>                <configuration>                    <source>1.8</source>                    <target>1.8</target>                    <encoding>UTF-8</encoding>                </configuration>            </plugin>        </plugins>    </build>

1. 2 第二种形式

在maven装置目录的conf文件夹下,批改settings.xml文件,在profiles节点里增加如下设置,如下图所示,设置为JDK1.8,此办法对所有Maven我的项目无效。

<profile>        <id>JDK1.8</id>        <activation>            <activeByDefault>true</activeByDefault>        </activation>        <properties>            <maven.compiler.source>1.8</maven.compiler.source>            <maven.compiler.target>1.8</maven.compiler.target>            <encoding>UTF-8</encoding>        </properties></profile>

2. maven 多模块打包,jar包和war输入到指定文件夹

maven多模块我的项目构造示例

父工程的pom中增加spring-boot-maven-plugin 的 outputDirectory

<properties>    <!-- properties中定义jar包的保留门路-->    <project.jar.output.directory>D:\JT\java\workspace\webvr-end\deploy</project.jar.output.directory></properties>  <build>    <pluginManagement>        <plugins>            <plugin>                <groupId>org.springframework.boot</groupId>                <artifactId>spring-boot-maven-plugin</artifactId>                <!-- 文件名以及输入门路-->                <configuration>                <!-- 1.0.5示意版本号-->                    <finalName>${project.artifactId}-1.0.5</finalName>                    <outputDirectory>${project.jar.output.directory}</outputDirectory>                </configuration>            </plugin>            <!-- 跳过启动测试 -->            <plugin>                <groupId>org.apache.maven.plugins</groupId>                <artifactId>maven-surefire-plugin</artifactId>                <configuration>                    <skipTests>true</skipTests>                </configuration>            </plugin>        </plugins>    </pluginManagement></build>

输入成果

在父工程下,执行
mvn clean package -Dmaven.test.skip=true

MVN命令

1. 常用命令

执行成果命令参数解释
Maven强制更新依赖mvn clean install -e -U-e具体异样,-U强制更新

2. 命令参数解释

本文转自:https://developer.aliyun.com/...