小编sim*_*mou的帖子

另一个未命名的CacheManager已经存在于同一个VM中(ehCache 2.5)

这是我运行junit测试时会发生的事情......

Another CacheManager with same name 'cacheManager' already exists in the same VM. Please 
provide unique names for each CacheManager in the config or do one of following:
1. Use one of the CacheManager.create() static factory methods to reuse same
   CacheManager with same name or create one if necessary
2. Shutdown the earlier cacheManager before creating new one with same name.

The source of the existing CacheManager is: 
 DefaultConfigurationSource [ ehcache.xml or ehcache-failsafe.xml ]
Run Code Online (Sandbox Code Playgroud)

异常背后的原因是什么?可以同时运行多个cacheManager吗?

这就是我使用Sping 3.1.1配置cachManager的方法.它将cacheManager的范围明确设置为"singleton"

<ehcache:annotation-driven />

<bean …
Run Code Online (Sandbox Code Playgroud)

junit spring ehcache

73
推荐指数
6
解决办法
7万
查看次数

gitolite:通道0上的PTY分配请求失败

jenkins(ci-server)和我的git存储库都托管在同一台服务器上.git repo由gitolite控制.如果我从外部访问存储库,例如从我的工作站访问,我得到

ssh git@arrakis

PTY allocation request failed on channel 0
hello simou, this is git@arrakis running gitolite3 v3.0-12-ge0ed141 on git 1.7.3.4

 R W    testing
Connection to arrakis closed.
Run Code Online (Sandbox Code Playgroud)

哪个好我猜(除了PTY ...警告)

现在回到服务器,我希望jenkins能够连接到我的git存储库.

jenkins@arrakis:~> ssh git@arrakis
gitolite: PTY allocation request failed on channel 0
Run Code Online (Sandbox Code Playgroud)

以用户git(gitolite用户)登录arrakis:

git@arrakis:~> cat ~git/.ssh/authorized_keys

command="/home/git/gitServer/gitolite/src/gitolite-shell jenkins",no-port-forwarding,no-x11-forwarding,no-agent-forwarding,no-pty ssh-rsa <PUBLIC-KEY> jenkins@arrakis
Run Code Online (Sandbox Code Playgroud)

"no-pty"条目让我很怀疑,所以我从authorized_keys中删除它并再次尝试:

jenkins@arrakis:~> ssh git@arrakis
hello jenkins, this is git@arrakis running gitolite3 v3.0-12-ge0ed141 on git 1.7.3.4

 R W    testing
Connection to arrakis closed.
Run Code Online (Sandbox Code Playgroud)

这解决了我的问题,但我不确定删除"no-pty"的后果.

为什么它只影响本地访问,因为远程访问似乎根本没有受到影响?


openSUSE 11.4(x86_64)VERSION = 11.4 …

gitolite

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

如何在Mockito和Scala中使用隐式匹配器来存根方法调用

我的应用程序代码使用AService

trait AService {
    def registerNewUser (username: String)(implicit tenant: Tenant): Future[Response]
}
Run Code Online (Sandbox Code Playgroud)

注册新用户.Class Tenant是一个简单的案例类:

case class Tenant(val vstNumber:String, val divisionNumber:String) 
Run Code Online (Sandbox Code Playgroud)

Trait AServiceMock通过使用模拟版本的AService来模拟注册逻辑

trait AServiceMock {
  def registrationService = {
    val service = mock[AService]
    service.registerNewUser(anyString) returns Future(fixedResponse)
    service
  }
}
Run Code Online (Sandbox Code Playgroud)

低,每当在AService上调用registerNewUser时,响应将是"fixedResponse"(在别处定义).

我的问题是,如何将隐式租户参数定义为像anyString一样的mockito匹配器?

顺便说一句.我正在使用Mockito和Specs2(和Play2)

scala implicit matcher mockito specs2

12
推荐指数
1
解决办法
3383
查看次数

Spring Data JPA:多个数据库/ Entitymanger配置的存储库

我有两个Entitymanagerbean配置.每个指向具有不同模式的单独数据库(一个是Oracle,另一个是内存中的H2)

我该怎么做才能解决Entitymanager应该用于每个存储库的模糊性?现在我收到这个错误:

 No unique bean of type [javax.persistence.EntityManagerFactory] is defined:
 expected single bean but found 2
Run Code Online (Sandbox Code Playgroud)

我想我可以通过使用类似的东西来提供快速修复

<jpa:repositories base-package="com.foo.repos.ora"
 entity-manager-factory-ref="entityManagerFactoryA">

<jpa:repositories base-package="com.foo.repos.m2"
 entity-manager-factory-ref="entityManagerFactoryB">
Run Code Online (Sandbox Code Playgroud)

但希望有更好的解决方案.

编辑:

我给你一个当前场景的想法:

Spring-Config:有两个EM

<jpa:repositories base-package="com.foo.repos.ora" entity-manager-factory-ref="entityManagerFactory"/>
<jpa:repositories base-package="com.foo.repos.m2" entity-manager-factory-ref="entityManagerFactory2"/>
<context:component-scan base-package="com.foo" />  ....
Run Code Online (Sandbox Code Playgroud)

这里的所有内容都在"package com.foo.repos.ora"中.遵循如何创建自定义存储库的模式我得到两个接口'ARepository','ARepositoryCustom'及其实现'ARepositoryImpl'就像这样

@Repository
public interface ARepository extends ARepositoryCustom, JpaRepository<myEntity, BigDecimal>, QueryDslPredicateExecutor {

}

public interface ARepositoryCustom {
    FooBar lookupFooBar()
}

public class ARepositoryImpl extends QueryDslRepositorySupport implements ARepositoryCustom {
    ARepositoryImpl(Class<?> domainClass) {
        super(domainClass.class)
    }

    ARepositoryImpl() {
        this(myEntity.class)
    }

    @Override
    FooBar …
Run Code Online (Sandbox Code Playgroud)

entitymanager multiple-databases spring-data-jpa

11
推荐指数
1
解决办法
2万
查看次数

Eclipse:如何保持项目源文件和ant build.xml与eclipse工作区分开?

我正在尝试重新熟悉Eclipse环境和ant集成.

问题是:如何保持我的源dir + build.xml与工作区分开?

我所拥有的是一个小型java项目及其build.xml文件,其中所有源都放在一个单独的项目文件夹下.然后我启动Eclipse并让它通过New Project导入我的项目 - >"现有Ant Build File中的Java项目"

一切顺利,直到我想使用build.xml从Eclipse内部构建项目.Ant开始抱怨无法找到源树.在我检查工作区后,我发现Eclipse已将build.xml复制到工作区中,因此很明显,ant无法在那里找到任何源代码.他们仍然在我的项目总监之下,如果可能的话,我确实想让他们留在那里.

那么最好的方法是什么让这个设置工作?一边是工作区,另一边是我的项目?

谢谢!

编辑:我想要的甚至可能吗?

eclipse ant workspace integration build.xml

9
推荐指数
2
解决办法
4879
查看次数

Circe和Scala的枚举类型

我正试图绕着Circe.

所以,这是我给出的模型:

object Gender extends Enumeration {
     type Gender = Value
     val Male, Female, Unisex, Unknown = Value
}

case class Product(id: String, gender: Gender.Value)
Run Code Online (Sandbox Code Playgroud)

我想要

a)将这个简单的例子编码为JSON字符串

        val product = Product(id = "1234", gender = Gender.Female)
Run Code Online (Sandbox Code Playgroud)

b)将生成的JSON映射回Product case类.


我自己的尝试并没有让我走得太远:

  object JsonProtocol {
      implicit val productDecoder: Decoder[Product] = deriveDecoder
      implicit val productEncoder: Encoder[Product] = deriveEncoder
  }
Run Code Online (Sandbox Code Playgroud)

导致编译时错误

   Error:(52, 49) could not find Lazy implicit value of type io.circe.generic.decoding.DerivedDecoder[A]
   implicit val productDecoder: Decoder[Product] = deriveDecoder
                                            ^
Run Code Online (Sandbox Code Playgroud)

我不知道为什么抛出这个异常以及解决方案看起来像什么.也许这是Enumeration类型的用法?但是,我只是在猜测.

json scala circe

6
推荐指数
3
解决办法
3311
查看次数

无法注册层:如何恢复 docker 删除 btrfs 子卷的情况?

[更新:事实证明这不是问题,请参阅下面我的评论]

因此,当我尝试使用“docker pull IMAGE”拉取图像时,我收到此错误:

failed to register layer: stat /var/lib/docker/btrfs/subvolumes/a8a6006af1d850f2dbb7052630731907fe6a2938af338a3c1a0f683e7ba178bf: no such file or directory
Run Code Online (Sandbox Code Playgroud)

它首先无法运行 docker 守护进程,因为我的机器上出现“设备上没有剩余空间”问题。由于删除较大的文件没有帮助,我开始使用以下命令删除 btrfs 子卷

for subvolume in /var/lib/docker/btrfs/subvolumes/*; do btrfs subvolume delete $subvolume; done
Run Code Online (Sandbox Code Playgroud)

(我从这里得到的https://github.com/moby/moby/issues/3894

现在我收到上述错误。

我现在正在寻找从头开始重新创建 docker 机器的方法,从新的 btrfs 文件系统开始。

码头工人信息

Server Version: 17.12.0-ce
Storage Driver: btrfs
Build Version: Btrfs v4.9.1
Library Version: 102
Run Code Online (Sandbox Code Playgroud)

docker

6
推荐指数
0
解决办法
2418
查看次数

如何在Tomcat中重新部署之前监视PermGen空间使用情况

为了确定在下一次重新调试之后jvm是否可能遇到permgen空间不足,我想先监测当前的permgen空间使用情况

就像是:

set myPermGenThreshold = 0.51  (51%)
currentlyUsedPermGenSize = (...ask the jvm here... say it's 0.6)

if (currentlyUsedPermGenSize > myPermGenThreshold ) {
 (...restart tomcat...)
}
else {
  (...redeploy application...)
}
Run Code Online (Sandbox Code Playgroud)

java tomcat permgen redeploy

2
推荐指数
1
解决办法
3422
查看次数