如何验证是否未在对象的依赖项上调用方法?
例如:
public interface Dependency {
    void someMethod();
}
public class Foo {
    public bar(final Dependency d) {
        ...
    }
}
Run Code Online (Sandbox Code Playgroud)
通过Foo测试:
public class FooTest {
    @Test
    public void dependencyIsNotCalled() {
        final Foo foo = new Foo(...);
        final Dependency dependency = mock(Dependency.class);
        foo.bar(dependency);
        **// verify here that someMethod was not called??**
    }
}
Run Code Online (Sandbox Code Playgroud) 我docker-compose.yml在两个不同的文件夹中有两个单独的文件:
如何确保容器中的容器~/front/docker-compose.yml可以向容器发送请求~/api/docker-compose.yml?
我知道front可以使用api单个容器设置该选项,以便可以为此容器分配特定的IP地址,但似乎此选项在使用时不可用--default-gateway.
目前我最终做了一个docker run并查看输出中的网关.它有效,但问题是这个IP是随机归因的,所以我不能依赖它.
因此,这个问题的另一种形式可能是:
但最后我要照顾的是:
我想为命令行安装MySQL客户端,而不是GUI.我在网上搜索过,但只找到了安装MySQL服务器的说明.
我试图在下面的Collectors.toMap()调用中为"keyMapper"函数参数提供一个更简洁的表达式:
List<Person> roster = ...;
Map<String, Person> map = 
    roster
        .stream()
        .collect(
            Collectors.toMap(
                new Function<Person, String>() { 
                    public String apply(Person p) { return p.getLast(); } 
                },
                Function.<Person>identity()));
Run Code Online (Sandbox Code Playgroud)
似乎我应该能够使用lambda表达式来内联它,但我无法想出一个编译它的人.(我对lambdas很新,所以这并不奇怪.)
谢谢.
- >更新:
如接受的答案所述
Person::getLast
Run Code Online (Sandbox Code Playgroud)
是我在寻找的东西,也是我尝试过的东西.然而,Eclipse 4.3的BETA_8每晚构建是问题 - 它标记为错误.从命令行编译时(我应该在发布之前完成),它起作用了.所以,是时候用eclipse.org提交bug了.
谢谢.
我有一个继承自其他的实体.另一方面,我使用lombok项目来减少样板代码,所以我把@Data注释.@Data带继承的注释会产生下一个警告:
生成equals/hashCode实现但不调用超类,即使此类不扩展java.lang.Object.如果这是故意的,请添加
@EqualsAndHashCode(callSuper=false)到您的类型.
是否可以添加注释@EqualsAndHashCode (callSuper = true)或@EqualsAndHashCode (callSuper = false)?如果没有添加,是哪一个callSuper=false或callSuper=true?
我已经成功创建了一个在内存中使用H2嵌入式数据库的spring启动应用程序.我现在想将其更改为基于文件的版本,该版本将持续存在.
我尝试过只更改文件中的spring.datasource.*属性application.properties,它们看起来像这样:
spring.datasource.url=jdbc:h2:file:~/test;DB_CLOSE_ON_EXIT=FALSE
spring.datasource.username=test
spring.datasource.password=test
spring.datasource.driverClassName=org.h2.Driver`  
Run Code Online (Sandbox Code Playgroud)
看起来像spring boot只是忽略了这些设置,因为它只是如下所示:
o.s.j.d.e.EmbeddedDatabaseFactory        : Starting embedded database: url='jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=false', username='sa'
Run Code Online (Sandbox Code Playgroud)
我pom.xml包含以下可能与此帖子相关的依赖项:
<parent>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-parent</artifactId>
  <version>1.3.5.RELEASE</version>
</parent>
....
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency> 
<dependency>
    <groupId>com.h2database</groupId>
    <artifactId>h2</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我从文档和一些帖子中了解到,配置应该正常工作,但对我来说没有运气.只是为了防止我尝试过的一些基本错误并检查以下内容:
@EnableAutoConfigurationdataSource带有注释组合的bean @Primary,@ConfigurationProperties(prefix = "spring.datasource")并以编程方式设置属性DataSourceBuilder.这会导致与类型相关的其他错误null.似乎我错过了一个关键概念或其他东西.谁能帮忙.
更新1:从我的自动配置报告中提取:
Positive matches:
-----------------
    DataSourceAutoConfiguration matched
  - @ConditionalOnClass classes found: javax.sql.DataSource,org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType (OnClassCondition)
   DataSourceAutoConfiguration.DataSourceInitializerConfiguration matched
  - @ConditionalOnMissingBean (types: org.springframework.boot.autoconfigure.jdbc.DataSourceInitializer; SearchStrategy: all) found no …Run Code Online (Sandbox Code Playgroud) 我试图在Mac上设置我的ssh配置(Mac OS Sierra 10.12.6),以便在密钥链中存储我的ssh密钥的密码.以前我可以这样做
ssh-add -K ~/.ssh/id_rsa
Run Code Online (Sandbox Code Playgroud)
但最近这似乎不再起作用了.在本文之后,似乎在Mac OS> 10.12.2中ssh配置的行为发生了变化,修复此问题的推荐方法是添加UseKeychain yes到您的ssh配置中.所以这是我的.ssh/config部分Host *:
Host *
  Port 22
  ServerAliveInterval 60
  ForwardAgent yes
  IdentityFile ~/.ssh/id_rsa
  AddKeysToAgent yes
  UseKeychain yes
Run Code Online (Sandbox Code Playgroud)
尝试ssh到外部主机时,我收到以下错误消息:
$ ssh my-host
/Users/USER/.ssh/config: line 16: Bad configuration option: usekeychain
Run Code Online (Sandbox Code Playgroud)
任何想法为什么会发生这种情况以及我如何解决它?谢谢!
我有一个jenkinsfile放入我的项目的根目录,并希望为我的管道拉入一个groovy文件并执行它.我能够让它工作的唯一方法是创建一个单独的项目并使用该fileLoader.fromGit命令.我想要做
def pipeline = load 'groovy-file-name.groovy'
pipeline.pipeline()
Run Code Online (Sandbox Code Playgroud) 我想访问的git变量,如GIT_COMMIT和GIT_BRANCH我已签出从混帐存储库构建流中进一步下跌.目前我找不到可用的变量来访问这两个参数.
node {
    git git+ssh://git.com/myproject.git
    echo "$GIT_COMMIT - $BRANCH_NAME"
}
Run Code Online (Sandbox Code Playgroud)
这些变量是否可用,万一,我会在哪里找到它们.我不介意他们是否可以通过一些常规变量或任何地方,只是我可以访问它们.
也许我缺乏Groovy的调试技巧,这很容易找到,但我只是用我有限的技能找不到它.
我从1.5.10移动到Spring Boot 2.0.0 RC1,我在最新版本中遇到了执行器.如何启用公开并启用所有执行器端点?
暴露的唯一端点是:
{
  "_links": {
    "self": {
      "href": "http://127.0.0.1:8080/actuator",
      "templated": false
    },
    "health": {
      "href": "http://127.0.0.1:8080/actuator/health",
      "templated": false
    },
    "info": {
      "href": "http://127.0.0.1:8080/actuator/info",
      "templated": false
    }
  }
}
Run Code Online (Sandbox Code Playgroud)
这是我的application.properties档案.有任何想法吗?
#The three first ones seem to be obsolete
endpoints.configprops.enabled=true
endpoints.beans.enabled=true
endpoints.shutdown.enabled=true
management.endpoints.enabled-by-default=true
management.endpoints.sensitive=false
management.endpoints.enabled=true
management.endpoint.configprops.enabled=true
management.endpoint.beans.enabled=true
management.endpoint.shutdown.enabled=true
management.endpoints.web.exposure.include=*
Run Code Online (Sandbox Code Playgroud) java ×4
groovy ×2
jenkins ×2
macos ×2
spring-boot ×2
collections ×1
docker ×1
git ×1
h2 ×1
java-8 ×1
java-stream ×1
lambda ×1
lombok ×1
macos-sierra ×1
mockito ×1
mysql ×1
networking ×1
spring ×1
ssh ×1
tdd ×1
terminal ×1