我有一个简单的Scala项目在Eclipse中运行没有任何问题,但是,当打包到.jar中时,我在运行它时会收到此异常:
Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: scala.util.matching.Regex.replaceAllIn(Ljava/lang/CharSequence;Lscala/Function1;)Ljava/lang/String;
这里发生了什么?...
有问题的代码行,以及完整的堆栈如下。
这是违规行:
"alt=\"[^>]+\">".r.replaceAllIn(inputStr, {_.replace(">", "/>")})
完整筹码:
Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: scala.util.matching.Regex.replaceAllIn(Ljava/lang/CharSequence;Lscala/Function1;)Ljava/lang/String;
at com.inosat.fuel.FuelStationDgge.fixhtml(FuelStationDgge.scala:40)
at com.inosat.fuel.FuelStationDgge.setDetails(FuelStationDgge.scala:82)
at com.inosat.fuel.DggeParser$$anon$1.propertyChange(DggeParser.scala:49)
at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source)
at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source)
at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source)
at org.jdesktop.beans.AbstractBean.firePropertyChange(AbstractBean.java:302)
at org.jdesktop.http.async.AsyncHttpRequest.setReadyState(AsyncHttpRequest.java:705)
at org.jdesktop.http.async.AsyncHttpRequest.access$600(AsyncHttpRequest.java:79)
at org.jdesktop.http.async.AsyncHttpRequest$AsyncWorker.done(AsyncHttpRequest.java:831)
at javax.swing.SwingWorker$5.run(Unknown Source)
at javax.swing.SwingWorker$DoSubmitAccumulativeRunnable.run(Unknown Source)
at sun.swing.AccumulativeRunnable.run(Unknown Source)
at javax.swing.SwingWorker$DoSubmitAccumulativeRunnable.actionPerformed(Unknown Source)
at javax.swing.Timer.fireActionPerformed(Unknown Source)
at javax.swing.Timer$DoPostEvent.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
答案 0 :(得分:1)
发现了什么错误,Eclipse正在使用scala-library.jar:
C:\eclipse\configuration\org.eclipse.osgi\bundles
由于某种原因,我从Scala的安装文件夹复制的jar是不一样的。 通过使用Eclipse正在使用的相同scala-library.jar 修复。