IDEA java compile and package into jar package

It is the first time to use IDEA to package it into a jar package.
Follow the online tutorial to package and find it.
Nothing works . The BUILD FAILURE
error message contains a bunch of useless information. The
information is as follows.

[INFO]
[INFO] ---------------------------< com.px82:other >---------------------------
[INFO] Building other 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ other ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 1 resource
[INFO] Copying 11 resources
[INFO] The encoding used to copy filtered properties files have not been set. This means that the same encoding will be used to copy filtered properties files as when copying other filtered resources. This might not be what you want
! Run your build with --debug to see which files might be affected. Read more at https://maven.apache.org/plugins/maven-resources-plugin/examples/filtering-properties-files.html
[INFO]
[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ other ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 184 source files to F:\project\AI\axc.px82.com\LoopV5\bsn_sdk_py\OtherSytemDemo\PCNGateway-Java-SDK-Demo2\other\target\classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  6.910 s
[INFO] Finished at: 2020-12-30T11:08:30+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile (default-compile) on project other: Compilation failure -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

After studying for an hour, I
finally summarized that
the error reported by directly executing mvn install in the command line is meaningless. Even if the -X parameter is added, it is of no use. If
you want to use the mouse in IDEA to execute it, it will report an error Content is valuable.

The first step is to check whether the compilation is successful. The
Insert picture description here
second step: confirm that there is no problem. The
Insert picture description here
third step: check maven, the file configuration in the directory D:\apache-maven-3.6.3\conf\settings.xml. To add Alibaba Cloud in China will effectively improve the speed of downloading jar packages. My configuration is as follows, added. Alibaba Cloud's mirror source

<mirrors> 
       <mirror>
            <id>alimaven</id>
            <mirrorOf>central</mirrorOf>
            <name>aliyun maven</name>
            <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
        </mirror>
        <mirror>
            <id>nexus-aliyun</id>
            <mirrorOf>*</mirrorOf>
            <name>Nexus aliyun</name>
            <url>http://maven.aliyun.com/nexus/content/groups/public</url>
        </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>

Step 4: Clean up first,
Insert picture description here
Step 5: Check whether the generated target is a jar package or a war package.
Insert picture description here

Step 6: Executing maven install
Insert picture description here
to this step has been packaged successfully.
To

Step 7: Execute the java command in the command line. java -r bsn-java.jar can start the website.

If there are some situations where the package cannot be opened. Or the version is incorrect. Please go to
https://mvnrepository.com/ to
check the corresponding version of the package.

Guess you like

Origin blog.csdn.net/phker/article/details/111953130