小编Ric*_*ich的帖子

如何获取Grails依赖项的源代码

如何让Ivy从Grails中下载依赖项的源代码?

我试图编辑的所有文件的ivy.xml我能找到的每本,但没有运气.

~/.grails/1.3.4/projects/workspace-sts/integration-files/ivy.xml
/c/grails-1.3.4/src/grails/ant/ivy.xml
Run Code Online (Sandbox Code Playgroud)

我一直在阅读grails源代码,但无法找到任何方法.有没有人有任何想法?

grails ivy

7
推荐指数
2
解决办法
2441
查看次数

获取或创建儿童Akka演员并确保活力

我试图使用Akka actor的层次结构来处理每个用户状态.有一个拥有所有子节点的父actor,并以正确的方式处理get-or-create(参见a1,a2):

class UserActorRegistry extends Actor {
  override def Receive = {
    case msg@ DoPerUserWork(userId, _) =>
      val perUserActor = getOrCreateUserActor(userId)
      // perUserActor is live now, but will it receive "msg"?
      perUserActor.forward(msg)
  }

  def getOrCreateUserActor(userId: UserId): ActorRef = {
    val childName = userId.toActorName
    context.child(childName) match {
      case Some(child) => child
      case None => context.actorOf(Props(classOf[UserActor], userId), childName)
  }
}
Run Code Online (Sandbox Code Playgroud)

为了回收内存,在UserActors一段闲置之后过期(即计时器触发子actor调用context.stop(self)).

我的问题是我认为我在"getOrCreateUserActor"和接收转发消息的子actor之间存在竞争条件 - 如果子进程在该窗口中到期,则转发的消息将丢失.

有什么方法可以检测到这种边缘情况,还是重构UserActorRegistry以排除它?

scala race-condition actor akka

6
推荐指数
1
解决办法
3288
查看次数

"找不到匹配的主机密钥类型" - Apache MINA SFTP服务器

我希望使用Apache MINA在Java中设置SFTP服务器.

它似乎开始正常,但当我尝试使用OpenSSH客户端连接到它时,我得到:

$ ssh localhost -p 2222
Unable to negotiate with ::1: no matching host key type found. Their offer: ssh-dss
$ ssh -V
OpenSSH_7.1p1, OpenSSL 1.0.2d 9 Jul 2015
Run Code Online (Sandbox Code Playgroud)

Java应用程序日志:

! java.lang.IllegalStateException: Unable to negotiate key exchange for server host key algorithms (client: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,ssh-rsa / server: ssh-dss)
! at org.apache.sshd.common.session.AbstractSession.negotiate(AbstractSession.java:1279) ~[sshd-core-1.0.0.jar:1.0.0]
Run Code Online (Sandbox Code Playgroud)

我的Maven依赖项是:

<dependency>
    <groupId>org.apache.sshd</groupId>
    <artifactId>sshd-sftp</artifactId>
    <version>0.11.0</version>
</dependency>

<dependency>
    <groupId>org.apache.sshd</groupId>
    <artifactId>sshd-core</artifactId>
    <version>1.0.0</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

我的应用启动代码看起来像(从/sf/answers/628216081/复制)

import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.server.Command;
import org.apache.sshd.server.SshServer;
import org.apache.sshd.server.auth.UserAuth;
import org.apache.sshd.server.auth.UserAuthNoneFactory;
import org.apache.sshd.server.command.ScpCommandFactory;
import …
Run Code Online (Sandbox Code Playgroud)

java apache-mina sshd

6
推荐指数
1
解决办法
4610
查看次数

innerHTML 将 CDATA 转换为注释

我正在尝试使用 javascript 将一些 HTML 插入到页面中,并且我插入的 HTML 包含 CDATA 块。

我发现在 Firefox 和 Chrome 中,CDATA 正在转换为注释。

HTML 不在我的控制之下,所以我很难避免使用 CDATA。

以下测试用例,当页面上有一个 id 为“test”的 div 时:

document.getElementById('test').innerHTML = '<![CDATA[foo]]> bar'
Run Code Online (Sandbox Code Playgroud)

导致以下 HTML 被应用到“测试”div:

<!--[CDATA[foo]]--> bar
Run Code Online (Sandbox Code Playgroud)

有什么方法可以使用javascript将包含CDATA的HTML逐字插入到文档中吗?

html javascript dom cdata

5
推荐指数
1
解决办法
3967
查看次数

在Java/Eclipse中推断变量类型,比如C#的"var"

我喜欢来自C#的"var"和来自Groovy的"def",我发现在Java中写出类型是一种痛苦.

说我写的代码如下:

List<LongTypeName> results = new ArrayList<LongTypeName>();
Run Code Online (Sandbox Code Playgroud)

要么

Map<TypeNameOne,TypeNameTwo> someLookup = fetchMeMyLookup();
Run Code Online (Sandbox Code Playgroud)

在Java + Eclipse中完成这项工作的最简单方法是什么?

我特别感兴趣的是我不能100%确定当我开始这条线时的类型.

我当前的策略是始终将变量声明为"int",然后返回到行的开头并执行"ctrl-1",并接受Eclipse推断的类型.还有更好的选择吗?

我喜欢的是能够键入"def"或"var"并让Eclipse自动将其更正为正确的类型,只要它能够解决它.

(也许我应该只是在Groovy中编程)

java eclipse shortcuts var function

5
推荐指数
2
解决办法
2514
查看次数

SBT如何在插件任务执行中使用Build.sbt中的类

project/*.scala文件中定义的任何类都可供构建定义代码中的SBT使用.

我希望这些类在执行SBT插件任务期间可用,但它们似乎不可用.

为什么会这样,我该如何解决?

我想解决的具体问题是添加自定义规则Scalastyle.该项目目前不支持编写自己的规则,但我认为我可以在project/*.sbt文件中添加规则然后在内部使用它Scalastyle.

如果我在中定义规则project/MyRule.scala,则它在project/Build.scala设置中可用:

object MyBuild extends Build {

  lazy val project = Project("MyProject", file("."))
    .settings(ScalastylePlugin.Settings: _*)

  // my rule is available in this classloader:
  val test = classOf[MyRule].getName

  ...
}
Run Code Online (Sandbox Code Playgroud)

...但是当ScalastylePlugin任务运行时,它使用的类加载器无法看到该类:

java.lang.NoClassDefFoundError: MyRule
java.net.URLClassLoader$1.run(URLClassLoader.java:202)
java.security.AccessController.doPrivileged(Native Method)
java.net.URLClassLoader.findClass(URLClassLoader.java:190)
java.lang.ClassLoader.loadClass(ClassLoader.java:307)
java.lang.ClassLoader.loadClass(ClassLoader.java:248)
java.lang.Class.forName0(Native Method)
java.lang.Class.forName(Class.java:169)
org.scalastyle.Checker$.newInstance(Checker.scala:194)
org.scalastyle.Checker$$anonfun$verifySource0$1.apply(Checker.scala:116)
org.scalastyle.Checker$$anonfun$verifySource0$1.apply(Checker.scala:116)
...
org.scalastyle.ScalastyleChecker.checkFiles(Checker.scala:64)
org.scalastyle.sbt.Tasks$.runScalastyle(Plugin.scala:121)
org.scalastyle.sbt.Tasks$.doScalastyle(Plugin.scala:90)
org.scalastyle.sbt.ScalastylePlugin$$anonfun$4$$anonfun$apply$1.apply(Plugin.scala:63)
org.scalastyle.sbt.ScalastylePlugin$$anonfun$4$$anonfun$apply$1.apply(Plugin.scala:63)
scala.Function6$$anonfun$tupled$1.apply(Function6.scala:35)
scala.Function6$$anonfun$tupled$1.apply(Function6.scala:34)
scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:42)
sbt.std.Transform$$anon$4.work(System.scala:64)
sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
sbt.Execute.work(Execute.scala:244)
sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:160)
sbt.CompletionService$$anon$2.call(CompletionService.scala:30)
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) …
Run Code Online (Sandbox Code Playgroud)

scala classloader sbt

5
推荐指数
1
解决办法
1198
查看次数

如何在 Linux JVM 中使用本机 Windows DLL

我在 DLL 文件中有一个带有本机函数(JNA)的简单 API,它只计算一些数学内容。我在 JAVA 应用程序中使用这个 DLL,在 Windows JVM 上一切正常。

问题是这个库将在 Linux JVM 内的 Linux 环境中使用,并且不会有 *.so 版本。

我读了几次,有一种方法可以在内存中加载带有 wine 的 DLL 并从那里使用它,但没有解释如何做到这一点。

有人可以为我确认或反驳这种方法。如果这真的是一个可能的解决方案,请告诉我该怎么做?

编辑:可能是如何在 Linux 上从 python 调用 Wine dll 中描述的解决方案我可以以某种方式使用 ctypes 吗?

问候 wurmi

java linux dll jvm wine

5
推荐指数
1
解决办法
2210
查看次数

Elasticsearch在不破坏语法的情况下突出显示HTML中的匹配项

Elasticsearch具有内置的“突出显示”功能,该功能使您可以在结果中标记匹配项(比起初听起来要复杂得多,因为查询语法可以包含接近匹配项等)。

我有HTML字段,当我打开突出显示功能时,Elasticsearch会遍历整个HTML语法。

以这种方式突出显示时,是否可以使其支持HTML / HTML安全?

我希望突出显示应用于HTML文档中的文本,而不是突出显示与搜索匹配的任何HTML标记,即搜索“ p”可能会突出显示<p>p</p>-> <p><mark>p</mark></p>

我的字段被索引为“ type: string”。

文件说

编码器:

编码器参数可用于定义突出显示的文本的编码方式。它可以是默认值(无编码)或html(如果使用html突出显示标签,则将转义html)。

..但HTML转义了我本来已经HTML编码的字段,使事情变得更糟。

这是两个示例查询

  1. 使用默认编码器:

高亮标签插入其他标签内,即<p>-> <<tag1>p</tag1>>

curl -XPOST -H 'Content-type: application/json' "http://localhost:7200/myindex/_search?pretty" -d '
{
  "query": { "match": { "preview_html": "p" } },
  "highlight": {
    "pre_tags" : ["<tag1>"],
    "post_tags" : ["</tag1>"],
    "encoder": "default",
    "fields": {
      "preview_html" : {}
    }
  },
  "from" : 22, "size" : 1
}'

GIVES:
...
      "highlight" : {
        "preview_html" : [ "<<tag1>p</tag1> class=\"text\">TOP STORIES</<tag1>p</tag1>><<tag1>p</tag1> …
Run Code Online (Sandbox Code Playgroud)

highlight elasticsearch

4
推荐指数
1
解决办法
3325
查看次数

Zend Server Windows - 授权标头未传递给PHP脚本

我有一个PHP应用程序,需要独立于包含Apache服务器执行HTTP基本身份验证.

在Linux机器上,通过安装php apt-get php,我发现Authorization标题没有出现$_SERVER,但可以通过apache_request_headers()getallheaders().

在使用Zend Server 6.1.0/PHP 5.4的Windows开发机器上,我无法Authorization通过上述任何方法从PHP内部获取标头值.我怎样才能获得它的价值?

mod_fcgid?

我无法确定它,但似乎Zend Server可能使用FCGI将Apache请求分派给PHP(例如,变量PHP_FCGI_MAX_REQUESTS出现在其中$_SERVER).

如果这是真的,它会解释我的问题,因为mod_fcgid故意Authorization从应用程序中删除标题,请参阅http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html#fcgidpassheader

我尝试添加

FcgidPassHeader Authorization
Run Code Online (Sandbox Code Playgroud)

对我的阿帕奇httpd.conf,但它只是抱怨:

Invalid command 'FcgidPassHeader', perhaps misspelled or defined by a module not included in the server configuration
Run Code Online (Sandbox Code Playgroud)

的mod_fastcgi?

同样,也许Zend正在使用mod_fastcgi?基于此页面http://www.fastcgi.com/mod_fastcgi/docs/mod_fastcgi.html#FastCgiConfig我尝试将以下内容添加到我的apache httpd.conf:

FastCgiConfig -pass-header Authorization
Run Code Online (Sandbox Code Playgroud)

再次,它只是抱怨说:

Invalid command 'FastCgiConfig', perhaps misspelled or defined by a module not included in the …
Run Code Online (Sandbox Code Playgroud)

php windows zend-framework apache2

3
推荐指数
1
解决办法
4450
查看次数

SQS ReceiveMessage 中的“MessageAttributeName.N”和“AttributeName.N”有什么区别

SQS“ReceiveMessage”端点有两个参数,它们似乎做同样的事情,但我不理解 API 文档。有人可以解释一下区别吗:

https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_ReceiveMessage.html

AttributeName.N
A list of attributes that need to be returned along with each message
Run Code Online (Sandbox Code Playgroud)
MessageAttributeName.N
The name of the message attribute, where N is the index.
...
When using ReceiveMessage, you can send a list of attribute names to receive, or you can return all of the attributes by specifying All
Run Code Online (Sandbox Code Playgroud)

看起来它们都做同样的事情,即指定在获取的消息上应返回哪些属性。有什么区别吗?如果不是,哪个是首选?

amazon-sqs amazon-web-services

3
推荐指数
1
解决办法
3823
查看次数