IDEA java 编译和打包成jar包

第一次用IDEA 也是第一次打包成jar包.
按照网上的教程进行打包发现.怎么都不行,
BUILD FAILURE
报错信息里面也是一堆无用的信息.
信息如下.

[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

研究了1个小时,
最后总结 一下,
在命令行里面直接执行 mvn install 所报的错误是没啥意义的.即便是加了-X 参数也没啥用.
要在IDEA里面用鼠标执行的时候报错内容才有价值.

第一步要看看编译是否成功.
在这里插入图片描述
第二步:确认无问题.
在这里插入图片描述
第三步:检查maven, 目录下D:\apache-maven-3.6.3\conf\settings.xml 中的文件配置.要加上国内的阿里云会有效提高下载jar包的速度. 我的配置如下 ,加了. 阿里云的镜像源

<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>

第四步: 先清理一下,
在这里插入图片描述
第五步:检查生成的目标是jar包还是war包.
在这里插入图片描述

第六步: 执行maven install
在这里插入图片描述
到这一步已经打包成功了.
到

第七步: 在命令行中执行java命令. java -r bsn-java.jar 即可启动网站.

如果出现一些打不了包的情况. 或者版本不对的情况. 请到
https://mvnrepository.com/
查询包的对应版本.

猜你喜欢

转载自blog.csdn.net/phker/article/details/111953130