将自定义Java程序加载到jruby中时,Intellij中出现“无法解析rubocopy响应”错误

问题描述 投票:0回答:1

jruby项目是在Intellij中创建的,并且是一个小的java模块,用于构建将由jruby模块调用的“ hello world” java程序。构建完jrubyjava模块后,我们可以看到jruby_hello.rb很“高兴”,jdk脚本可以访问java.util.TreeSet中的com.example.[CallMe, ISpeaker]-和jruby_hello.rb中的自定义类:

enter image description here

但是-运行jruby代码时,发生以下错误:

enter image description here

这是rubocop响应:

错误:jruby.jar是/usr/local/opt/jruby/libexec/lib/jruby.jar{“元数据”:{“ rubocop_version”:“ 0.79.0”,“ ruby​​_engine”:“ jruby”,“ ruby​​_version”:“ 2.5.7”,“ ruby​​_patchlevel”:“ 0”,“ ruby​​_platform”:“ java”} ,“文件”:[{“路径”:“ jruby_hello.rb”,“攻击”:[{“严重性”:“会议”,“消息”:“缺少魔术注释# frozen_string_literal: true。”,“警察名”:” Style / FrozenStringLiteralComment“,”更正“:false,”更正“:true,”位置“:{” start_line“:1,” start_column“:1,” last_line“:1,” last_column“:1,” length“: 1,“ line”:1,“ column”:1}},{“ severity”:“ convention”,“ message”:“当您不需要字符串插值或特殊符号时,建议使用单引号。”,“ cop_name“:” Style / StringLiterals“,” corrected“:false,” correctable“:true,” location“:{” start_line“:1,” start_column“:9,” last_line“:1,” last_column“:14, “ length”:6,“ line”:1,“ column”:9}},{“ severity”:“ convention”,“ message”:“当不需要字符串插值或特殊符号时,建议使用单引号。“,” cop_name“:” Style / StringLiterals“,” corrected“:false,” correctable“:true ...

enter image description here

我们可以注意到错误输出中隐藏的是

  "message":"Missing magic comment `# frozen_string_literal: true`."

解决此问题需要什么?

jruby
1个回答
0
投票

在文件顶部添加该字符串似乎已经解决了问题

# frozen_string_literal: true
require "java"

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.