001-idea maven configuration

  • Download and unzip

Pay attention to version issues. Idea2018.02 version supports 3.5.2 version maven. If the higher version does not support it, an error will be reported: Unable to import maven project: See logs for details

可参考README.txt
  JDK:
    1.7 or above (this is to execute Maven - it still allows you to build against 1.3
    and prior JDK's).

  • Environment variable configuration

Path add: %MAVEN_HOME%\bin

  • Modify bin/mvn.cmd to add JAVA_HOME, so that mvn commands can be executed in cmd

@setlocal

set "JAVA_HOME=D:\dev\dev-lib\jdk-11.0.10+9"
set "MAVEN_OPTS=-Xms128m -Xmx1024m -XX:MaxPermSize=512m -XX:ReservedCodeCacheSize=64m"

set ERROR_CODE=0

@REM ==== START VALIDATION ====

  • Modify the conf-/setting.xml file

3. Modify the central warehouse. The default is abroad, and it is very slow in domestic use. I use Ali's central warehouse here, or NetEase or Apache.

At the same time, the default central warehouse is configured. When the Ali image lacks jar packages, it will be automatically downloaded from the central warehouse.

Modify the conf-/setting.xml file

 


  <mirrors>
        <!-- 阿里云仓库 -->
	<mirror>
	  <id>alimaven</id>
	  <name>aliyun maven</name>
	  <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
	  <mirrorOf>central</mirrorOf>
	</mirror>
        <!-- 中央仓库1 -->
        <mirror>
            <id>repo1</id>
            <mirrorOf>central</mirrorOf>
            <name>Human Readable Name for this Mirror.</name>
            <url>http://repo1.maven.org/maven2/</url>
        </mirror>
        <!-- 中央仓库2 -->
        <mirror>
            <id>repo2</id>
            <mirrorOf>central</mirrorOf>
            <name>Human Readable Name for this Mirror.</name>
            <url>http://repo2.maven.org/maven2/</url>
        </mirror>
  </mirrors>

4. Configure the default JDK version

4.1. Global configuration : modify the settings.xml file in the maven installation directory, add the profiles tag:

<profile>
    <id>jdk-1.8</id>
     <activation>
        <activeByDefault>true</activeByDefault>
        <jdk>1.8</jdk>
      </activation>
    <properties> 
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
    </properties>
</profile>

4.2. Project-level configuration : Specify the jdk version in the pom.xml of the project-only the current project is guaranteed

---jdk11:

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <release>11</release>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
        </plugins>
    </build>

--- jdk8:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.0</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
                <encoding>UTF-8</encoding>
            </configuration>
        </plugin>
    </plugins>
</build>

5.idea is configured as the maven just downloaded

6. Updating indexes is that Maven is downloading and updating, this needs to be set manually: 

Window --> Preferences --> Maven --> Remove the check before Download repository index updates on startup, and then restart the software.

7. For oralce's jdbc driver, although it can be searched in the maven warehouse, it seems to be unusable. The reason is that oracle is charged and cannot be introduced remotely. It can only be loaded into the project by configuring the local library

mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc8 -Dversion=12.2.0.1 -Dpackaging=jar -Dfile=D:\now\ojdbc8.jar

 

 

 

Guess you like

Origin blog.csdn.net/mnbwz/article/details/109563005