windows 使用 IDEA,通过 maven 打包一个开源项目的求助

85 天前
 baiyekaslana

https://github.com/devlive-community/datacap.git 本地打算源码打包安装 datacap 项目,但是现在 jdk 使用 1.8 版本的话,后面打包就会提示 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.13.0:compile (java-compile) on project datacap-captcha: Fatal error compiling: 无效的目标发行版: 11 -> [Help 1] 让你使用 jdk11. 要是使用 jdk11 的话,开始就会提示无法找到 tools.jar,要用 tools.jar 就得换回 jdk1.8 我想知道这个开源项目源码到底要怎么打包。

1792 次点击
所在节点    Java
31 条回复
a33291
85 天前
jvav 这么无敌的兼容性,编译用 11,然后把 8 的 tools.jar 放到 11 的 classpath 不就好了
baiyekaslana
85 天前
@a33291 试过了,还是提示没有 tools.jar
zypy333
85 天前
无效的目标发行版: 11 是你的项目里有些配置不对吧,到 compiler 跟 module 选项里检查下
sagaxu
85 天前
不要用 IDEA ,直接在命令行下面打包
ikas
85 天前
这个项目需要 jdk11 以上
你的 idea 是不是版本太低,里面内置的 maven 版本太低,还是指定了较低版本的 maven?

项目 sdk 设置为 jdk11+
然后 idea 设置中将 maven 指定为 3.7+,另外 maven runner 设置使用项目 jdk

已经测试 idea2024.2 jdk21 正常编译
1462326016
85 天前
@ikas #5 +1 实测 jdk11 正常编译,版本号如下
-Didea.version=2024.2.2
openjdk@11/11.0.24
apache-maven-3.6.3
Belmode
85 天前
https://imgur.com/Lpd93n5
这是 OP 问的吧,对方已经修复了这个问题,不过编译还是至少使用 JDK11+

相关文档: https://datacap.devlive.org/developer/server/home.html

我简单看了一下,这个项目挺不错的,就是不知道稳定性怎么样。
baiyekaslana
84 天前
@ikas 提示找不到 tools.jar,好像是引用的时候有个..到上一级目录,是 jdk-11/../lib/tools.jar,然后把 lib 复制到外面之后就不报这个错了,我用的 jdk11,和 maven3.6.3 版本,现在是 clean 正常,但是 package 的时候又报错了,idea 是 2023.3.6 版本
baiyekaslana
83 天前
@ikas ./mvnw -T 1C clean install package -Dspotbugs.skip -Dgpg.skip -Dcheckstyle.skip -DskipTests=true
在那个官网上,说要使用命令行执行这个,但是我用 idea 就提示识别不了.skip ,用的 windows10 ,要加这些参数再 idea 上能加嘛,还是只能去 pom 文件里加
ikas
83 天前
这些参数只是跳过一些执行操作.

如果你非要在 idea 中操作,那么
我建议先不用 mvnw,而是在设置中将 maven 指定为自己下载的

> idea 设置中将 maven 指定为 3.7+,另外 maven runner 设置使用项目 jdk

这些参数可以在 idea 的 maven 边栏的工具栏中,有个执行命令的按钮,点击输入 package -Dspotbugs.skip -Dgpg.skip -Dcheckstyle.skip -DskipTests=true 即可
baiyekaslana
83 天前
@ikas 没想非要执行这些操作,就是现在 maven 这些都配置了,jdk 也配置了,然后编译和 maven 的操作都有报错
baiyekaslana
83 天前
@ikas 构建的时候还有个 gpg 认证的吧,这个不跳过不行吧?
ikas
83 天前
一般都是习惯配置好 maven path,直接 mvn compile,有啥错就看看,该跳肯定跳.....
主要是 idea 对 maven 项目导入太慢
baiyekaslana
83 天前
@ikas 除啦这个 maven 配置和 jdk 配置还需要啥操作嘛,我 idea 换成 24.2.2 也还是不行
ikas
83 天前
是不是你的网络有问题,这个项目还有前端项目(datacap-server datacap-ui)需要编译的,会自动下载 node 等,如果没法访问 github 是不行的

mvn compile -U -Dspotbugs.skip -Dgpg.skip -Dcheckstyle.skip -DskipTests=true


[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for datacap 2024.3.10-SNAPSHOT:
[INFO]
[INFO] datacap ............................................ SUCCESS [ 21.434 s]
[INFO] datacap-captcha .................................... SUCCESS [ 0.292 s]
[INFO] datacap-fs-spi ..................................... SUCCESS [ 0.062 s]
[INFO] datacap-scheduler-spi .............................. SUCCESS [ 5.759 s]
[INFO] datacap-common ..................................... SUCCESS [ 4.450 s]
[INFO] datacap-client-cli ................................. SUCCESS [ 3.201 s]
[INFO] datacap-parser ..................................... SUCCESS [ 0.127 s]
[INFO] datacap-shaded-pinot ............................... SUCCESS [ 1.962 s]
[INFO] datacap-convert-spi ................................ SUCCESS [ 1.012 s]
[INFO] datacap-convert-txt ................................ SUCCESS [ 1.500 s]
[INFO] datacap-convert-json ............................... SUCCESS [ 1.101 s]
[INFO] datacap-convert-none ............................... SUCCESS [ 0.690 s]
[INFO] datacap-convert-csv ................................ SUCCESS [ 0.695 s]
[INFO] datacap-convert-xml ................................ SUCCESS [ 0.709 s]
[INFO] datacap-spi ........................................ SUCCESS [ 4.657 s]
[INFO] datacap-sql ........................................ SUCCESS [ 1.532 s]
[INFO] datacap-schedule ................................... SUCCESS [ 2.160 s]
[INFO] datacap-parser-spi ................................. SUCCESS [ 0.562 s]
[INFO] datacap-parser-trino ............................... SUCCESS [ 8.260 s]
[INFO] datacap-parser-mysql ............................... SUCCESS [ 16.018 s]
[INFO] datacap-scheduler-local ............................ SUCCESS [ 0.412 s]
[INFO] datacap-executor-spi ............................... SUCCESS [ 0.713 s]
[INFO] datacap-executor-local ............................. SUCCESS [ 0.435 s]
[INFO] datacap-logger ..................................... SUCCESS [ 2.013 s]
[INFO] datacap-shell ...................................... SUCCESS [ 2.330 s]
[INFO] datacap-executor-seatunnel ......................... SUCCESS [ 2.500 s]
[INFO] datacap-service .................................... SUCCESS [ 6.519 s]
[INFO] datacap-security ................................... SUCCESS [ 3.060 s]
[INFO] datacap-jdbc-mysql ................................. SUCCESS [ 2.226 s]
[INFO] datacap-jdbc-clickhouse ............................ SUCCESS [ 2.236 s]
[INFO] datacap-jdbc-presto ................................ SUCCESS [ 2.184 s]
[INFO] datacap-driver-redis ............................... SUCCESS [ 0.048 s]
[INFO] datacap-jdbc-redis ................................. SUCCESS [ 2.249 s]
[INFO] datacap-jdbc-trino ................................. SUCCESS [ 2.567 s]
[INFO] datacap-jdbc-postgresql ............................ SUCCESS [ 2.266 s]
[INFO] datacap-jdbc-elasticsearch ......................... SUCCESS [ 2.277 s]
[INFO] datacap-jdbc-druid ................................. SUCCESS [ 2.245 s]
[INFO] datacap-jdbc-kyuubi ................................ SUCCESS [ 2.232 s]
[INFO] datacap-jdbc-hive .................................. SUCCESS [ 4.242 s]
[INFO] datacap-jdbc-kylin ................................. SUCCESS [ 2.198 s]
[INFO] datacap-jdbc-ignite ................................ SUCCESS [ 2.187 s]
[INFO] datacap-jdbc-db2 ................................... SUCCESS [ 2.354 s]
[INFO] datacap-jdbc-dremio ................................ SUCCESS [ 2.227 s]
[INFO] datacap-jdbc-monetdb ............................... SUCCESS [ 2.136 s]
[INFO] datacap-jdbc-phoenix ............................... SUCCESS [ 6.836 s]
[INFO] datacap-jdbc-h2 .................................... SUCCESS [ 2.117 s]
[INFO] datacap-jdbc-sqlserver ............................. SUCCESS [ 2.139 s]
[INFO] datacap-jdbc-oracle ................................ SUCCESS [ 2.174 s]
[INFO] datacap-jdbc-cratedb ............................... SUCCESS [ 2.256 s]
[INFO] datacap-jdbc-dm .................................... SUCCESS [ 2.117 s]
[INFO] datacap-http-cratedb ............................... SUCCESS [ 2.243 s]
[INFO] datacap-http-clickhouse ............................ SUCCESS [ 2.122 s]
[INFO] datacap-jdbc-tdengine .............................. SUCCESS [ 2.241 s]
[INFO] datacap-jdbc-impala ................................ SUCCESS [ 2.278 s]
[INFO] datacap-jdbc-oceanbase ............................. SUCCESS [ 2.120 s]
[INFO] datacap-native-redis ............................... SUCCESS [ 2.157 s]
[INFO] datacap-jdbc-neo4j ................................. SUCCESS [ 2.175 s]
[INFO] datacap-jdbc-iotdb ................................. SUCCESS [ 2.360 s]
[INFO] datacap-jdbc-snowflake ............................. SUCCESS [ 2.187 s]
[INFO] datacap-shaded-ydb ................................. SUCCESS [ 1.255 s]
[INFO] datacap-jdbc-ydb ................................... SUCCESS [ 2.128 s]
[INFO] datacap-native-zookeeper ........................... SUCCESS [ 2.257 s]
[INFO] datacap-jdbc-duckdb ................................ SUCCESS [ 2.111 s]
[INFO] datacap-native-alioss .............................. SUCCESS [ 2.343 s]
[INFO] datacap-native-kafka ............................... SUCCESS [ 2.204 s]
[INFO] datacap-native-h2 .................................. SUCCESS [ 2.229 s]
[INFO] datacap-http-ceresdb ............................... SUCCESS [ 2.282 s]
[INFO] datacap-http-greptime .............................. SUCCESS [ 2.315 s]
[INFO] datacap-http-questdb ............................... SUCCESS [ 2.283 s]
[INFO] datacap-jdbc-doris ................................. SUCCESS [ 0.357 s]
[INFO] datacap-jdbc-starrocks ............................. SUCCESS [ 0.299 s]
[INFO] datacap-jdbc-hologres .............................. SUCCESS [ 0.312 s]
[INFO] datacap-native-hdfs ................................ SUCCESS [ 0.678 s]
[INFO] datacap-plugin-pinot ............................... SUCCESS [ 0.441 s]
[INFO] datacap-driver-mongo ............................... SUCCESS [ 0.019 s]
[INFO] datacap-plugin-mongo-community ..................... SUCCESS [ 0.318 s]
[INFO] datacap-plugin-cassandra ........................... SUCCESS [ 0.652 s]
[INFO] datacap-plugin-matrixone ........................... SUCCESS [ 0.288 s]
[INFO] datacap-plugin-scylladb ............................ SUCCESS [ 0.434 s]
[INFO] datacap-plugin-paradedb ............................ SUCCESS [ 0.249 s]
[INFO] datacap-plugin-timescale ........................... SUCCESS [ 0.245 s]
[INFO] datacap-plugin-solr ................................ SUCCESS [ 0.262 s]
[INFO] datacap-plugin-influxdb ............................ SUCCESS [ 0.244 s]
[INFO] datacap-fs-local ................................... SUCCESS [ 2.098 s]
[INFO] datacap-fs-qiniu ................................... SUCCESS [ 0.466 s]
[INFO] datacap-fs-alioss .................................. SUCCESS [ 0.429 s]
[INFO] datacap-fs-tencent-cos ............................. SUCCESS [ 0.392 s]
[INFO] datacap-fs-amazon-s3 ............................... SUCCESS [ 0.405 s]
[INFO] datacap-fs-minio ................................... SUCCESS [ 0.458 s]
[INFO] datacap-notify-spi ................................. SUCCESS [ 0.265 s]
[INFO] datacap-http ....................................... SUCCESS [ 2.213 s]
[INFO] datacap-notify-dingtalk ............................ SUCCESS [ 0.314 s]
[INFO] datacap-server ..................................... SUCCESS [01:35 min]
[INFO] datacap-jdbc-mongo ................................. SUCCESS [ 8.526 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 05:07 min
[INFO] Finished at: 2024-09-29T22:14:54+08:00
[INFO] ------------------------------------------------------------------------
ikas
83 天前
我的环境是就是 idea 24.2, Maven 3.8.5, Jdk 21 ,maven 使用腾讯云的镜像
baiyekaslana
83 天前
@ikas [ERROR] Unknown lifecycle phase ".skip". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, init
ialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]
我加参数就会提示这个
baiyekaslana
83 天前
@baiyekaslana
@ikas 这个错误找到了,windows 的 power shell 终端执行这个命令需要在每个参数两边加单引号
mvn compile -U '-Dspotbugs.skip' '-Dgpg.skip' '-Dcheckstyle.skip' -DskipTests=true
我执行这样就行了
baiyekaslana
83 天前
之前问 gpt 也没提示
baiyekaslana
83 天前
@ikas [ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.15.0:yarn (yarn install) on project datacap-server: Failed to run task: 'yarn --legacy-peer-deps install' failed. org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1) -> [Help 1]
本地已经下载 yarn ,path 里也加了,但是还是报这个错误

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/1076400

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX