Aug 11
# 现象

手头有一个比较大的maven project,拆成了十几个module,如果我要在 Intellij IDEA 跑个单测什么的,就会报错,各种依赖找不到,即使 pom.xml 里是明明白白写着:

点击在新窗口中浏览此图片

依然无法识别,连 lombok 和 junit 都不行:

点击在新窗口中浏览此图片

尽管 idea 很好心地给了帮助 "Add JUnit4 to classpath",点击后也只是在 pom.xml 里再添加一次,并没有什么卵用。

这个问题有个很灵异的现象是,每次用 "mvn clean install" 整体编译的时候是正常的,但是在 idea 跑 test case,或启动某个 main,就会报错。


# 排查

打开 Project Structure 可以看到,这个 module 的 dependency 全是空的:

点击在新窗口中浏览此图片

说明 pom.xml 文件应该是有坑。

查看 maven reload 的output,发现是了问题是某个dependency没有指定版本号

引用
[ERROR] org.apache.maven.artifact.InvalidArtifactRTException: For artifact {org.apache.flink:flink-streaming-java_2.11:null:jar}: The version cannot be empty.


参考其他 module 指定正确的版本号:

引用
<version>1.10.1</version>


再重新reload,问题就解决了。


# 回顾

再回头想想前面提到的灵异现象,从结果倒推,大概是因为把项目作为整体编译的时候,同一个package只能有一个版本,即使模块A没有指定版本,只要模块B有指定,就能正常引用。

之前还遇到过另一个现象,整体编译没问题,但是在 iDEA 里跑单测的时候,会发现引用了旧版本,其实也是同样的问题了。


完。
Aug 9
遥想第一次听说Google Authenticator已经是 7年前的事情 了,那时候它还托管在 Google Code 上(缅怀)。

说来惭愧,那会儿我就已经用着 SecureCRT 好几年了,就在D厂的时候大家都在用的那个D版。今年终于咬牙买了个正版,突然意识到它的Logon Script可以用来搞这个两步认证,上网搜了一下,已经有大神写好放在 gist 上了,于是抄了一把,略作改动,贴在这里。

注意:
1. 记得要把 SecureCRT session option里 Login Actions → "Display logon prompts in terminal window" 勾上。
2. 这个版本是windows版用的,保存成py文件;用mac版的同学,要看下scrt的脚本引擎是py2还是py3,py3的话,得用原作者这个 gist 里的另一个版本

# $language = "python"
# $interface = "1.0"

import hmac, base64, struct, hashlib, time, json, os

TOTP_KEY = 'YOUR_TOTP_KEY'
YOUR_PASSWD = 'PASSWORD'

def get_hotp_token(secret, intervals_no):
  """This is where the magic happens."""
  key = base64.b32decode(normalize(secret), True) # True is to fold lower into uppercase
  msg = struct.pack(">Q", intervals_no)
  h = hmac.new(key, msg, hashlib.sha1).digest()
  o = ord(h[19]) & 15
  h = str((struct.unpack(">I", h[o:o+4])[0] & 0x7fffffff) % 1000000)
  return prefix0(h)


def get_totp_token(secret):
  """The TOTP token is just a HOTP token seeded with every 30 seconds."""
  return get_hotp_token(secret, intervals_no=int(time.time())//30)


def normalize(key):
  """Normalizes secret by removing spaces and padding with = to a multiple of 8"""
  k2 = key.strip().replace(' ','')
  # k2 = k2.upper()  # skipped b/c b32decode has a foldcase argument
  if len(k2)%8 != 0:
    k2 += '='*(8-len(k2)%8)
  return k2


def prefix0(h):
  """Prefixes code with leading zeros if missing."""
  if len(h) < 6:
    h = '0'*(6-len(h)) + h
  return h


def main():
  tab = crt.GetScriptTab()

  if tab.Session.Connected != True:
    crt.Dialog.MessageBox("Session Not Connected")
    return

  tab.Screen.Synchronous = True
  tab.Screen.WaitForStrings(['[MFA auth]:'])
  vc = get_totp_token(TOTP_KEY)
  tab.Screen.Send("{vc}\r\n".format(vc=vc))
  tab.Screen.WaitForStrings(['Opt>'])
  tab.Screen.Send("relay2\r\n")
  if tab.Screen.WaitForString('password:', 1):
      tab.Screen.Send("{pwd}\r\n".format(pwd=YOUR_PASSWD)) #鄙厂的relay后面还有个relay
  return

main()


REF:
https://gist.github.com/hex-ci/a8c58ac049c4b3a05ef2d6f9d98193c2
Aug 1
~/.bashrc 中加上以下内容即可:
引用
export LANG=zh_CN.UTF-8


如果 git 命令(如 git diff)下仍有代码,可以再增加
引用
export LESSCHARSET=UTF-8


如果 vim 下依然有乱码,在 .vimrc 中增加
引用
set encoding=utf-8
set termencoding=utf-8


--

参考资料:
- Mac下使用SecureCRT时中文乱码问题解决
  https://blog.csdn.net/BabyFish13/article/details/101463105

- 记一次secureCRT中文乱码解决过程
  https://yunchangyue.github.io/blog/tools/2018/11/16/securecrt/
分页: 1/1 第一页 1 最后页 [ 显示模式: 摘要 | 列表 ]