小编Gre*_*egg的帖子

Grails REST Client插件 - 指定标题数据

最新版本的Grails REST客户端插件:

withHttp(uri: "http://foo/bar") {
    def bodyContent = [
           apiKey: "somekey",
           identifier: identity.identity,
           activity: ac as JSON
        ]
    def json = post(path: 'activity', body: bodyContent)
    if (json.stat == 'ok') {
        wsr.success = true
    }
}
Run Code Online (Sandbox Code Playgroud)

如何向此请求添加标头数据?

rest grails grails-plugin httpbuilder

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

将livequery转换为live/delegate /?

搜索没有透露我的问题的解决方案,所以在这里问.我一直在使用livequery()一段时间与live()结合使用.通常,我将live()用于已知事件(如click),但使用livequery触发特定选择器并应用插件.例如...

$('#childDomains').livequery(function() {
  var element = $(this);
  element.jqGrid({
    // plugin initialization here
  });
});
Run Code Online (Sandbox Code Playgroud)

我想知道是否有办法使用live()/ delegate()或其他一些我不知道的酷jQuery功能做同样的事情.我试图减轻我的依赖负载,我注意到自2010年2月至2010年以来没有更新livequery.

更新:我想我不够清楚.我有一个页面使用jqGrid并将TABLE元素转换为jqGrid Ajax数据网格.没有真正的点击事件发生这种情况.该表所在的页面是通过ajax加载的,只要DOM看到$("#childDomains"),它就应该将jqGrid插件应用于该元素.就像我的livequery示例一样.

根据我的理解,到目前为止,我不相信没有实时查询这是可能的,但我想要求确认.

jquery livequery

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

使用Git和部署密钥构建Jenkins

我将git插件添加到Jenkins.我在构建服务器上生成了一个公钥作为jenkins用户.我将此密钥添加为github的Deploy Key.我已经使用jenkins名称和电子邮件添加了全局git属性,并且电子邮件与公钥末尾的内容匹配.

当Jenkins试图从git存储库(在Github上托管)中提取时,我得到以下内容:

Started by user anonymous
Building in workspace /var/lib/jenkins/jobs/Test Deployment/workspace
Checkout:workspace / /var/lib/jenkins/jobs/Test Deployment/workspace - hudson.remoting.LocalChannel@9ba3afe
Using strategy: Default
Cloning the remote Git repository
Cloning repository origin
ERROR: Error cloning remote repo 'origin' : Could not clone git@github.com:GenRocket/GenRocket.git
hudson.plugins.git.GitException: Could not clone git@github.com:GenRocket/GenRocket.git
    at hudson.plugins.git.GitAPI.clone(GitAPI.java:245)
    at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1121)
    at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1063)
    at hudson.FilePath.act(FilePath.java:839)
    at hudson.FilePath.act(FilePath.java:821)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1063)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1218)
    at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:586)
    at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:475)
    at hudson.model.Run.run(Run.java:1438)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:239)
Caused by: hudson.plugins.git.GitException: Command "git clone --progress -o origin …
Run Code Online (Sandbox Code Playgroud)

git github jenkins

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

在非活动选项卡上使用Bootstrap装饰的DataTable具有窄头

我正在使用带有Bootstrap的DataTables并将其全部工作.然后我需要一个选项卡中的表格,当我这样做时,表格标题开始变窄,恰好适合标题文本的宽度.如果在显示页面时选项卡处于活动状态,则表格看起来很棒.你可以看到我的意思的一个例子.标签1看起来很好.标签2具有窄标题.

如果我启用排序并单击选项卡2上的列,则标题将扩展为适当的宽度,但始终开始缩小.

datatables twitter-bootstrap

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

在IntelliJ IDEA中更改Grails SDK不适用于插件模块

IDEA 11.1.2

我有一个我需要升级的Grails应用程序.该应用程序包含几个模块.一个是应用程序,另一个是插件.我右键单击了应用程序并转到Grails - >更改SDK版本.我选择了我想要的版本,然后IDEA问我是否要升级应用程序.点击是,一切都很好.

我一直在尝试在插件模块上做同样的事情.IDEA从未询问我是否要升级,似乎没有更改SDK.如果我从命令行升级模块,当我回到IDEA时,它认为存在版本不匹配并且在没有询问的情况下自动降级我.

这有解决方法吗?

grails intellij-idea

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

Grails 2.2.0 URLMappings:使用不同动词的相同URL的任何方式

我有以下内容:

"/api/users"(controller: "user") {
   action = [GET:"list"]
}
Run Code Online (Sandbox Code Playgroud)

打电话给http://localhost:8080/platform/users我得到一个用户列表.然后我添加了这个:

"/api/users"(controller: "user") {
   action = [POST:"save"]
}
Run Code Online (Sandbox Code Playgroud)

现在我得到一个404,它没有击中UserController中的任何一个方法.我希望能够使用相同的URL和动词控制哪个动作.我做错了还是Grails不支持这个?

grails url-mapping

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

Android单元测试未报告失败失败()

我编写了一个单元测试,只是扩展了TestCase,我有以下内容:

public class MetricParserTests extends TestCase {

    @Override
    protected void setUp() throws Exception {
        super.setUp();
    }

    @Override
    protected void tearDown() throws Exception {
        super.tearDown();
    }

    public void testFailure() {
        fail("This needs to fail");
    }
}
Run Code Online (Sandbox Code Playgroud)

当我使用测试运行ant testadb shell am instrument得到以下结果时:

... [exec] OK(1次测试)......

我希望在命令行上看到失败.

ant junit android unit-testing

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

Ember.选择内容与contentBinding

Ember.Select的文档使用以下内容:

{{view Ember.Select content=foo ... }}
Run Code Online (Sandbox Code Playgroud)

但是,该指南使用以下内容

{{view Ember.Select contentBinding="foo" ... }}
Run Code Online (Sandbox Code Playgroud)

两者都有效.哪个是首选,为什么?

ember.js

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

使用 JPA 存储枚举值

说我有一个枚举:

public enum NotificationType {

    Store("S"),
    Employee("E"),
    Department("D"),
    All("A");

    public String value;

    NotificationType(String value) {
        this.value = value;
    }
}
Run Code Online (Sandbox Code Playgroud)

我想在数据库中存储SorE而不是Storeor Employee。目前,我已将其映射到实体中,如下所示:

@Enumerated(EnumType.STRING)
private NotificationType notificationType;
Run Code Online (Sandbox Code Playgroud)

但如果可能的话,不确定如何得到我想要的东西。

java enums spring hibernate jpa

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

使用 @WebMvcTest 进行单元测试 POST - @MockBean Service 返回 null

我正在尝试对控制器进行单元测试以保存Brand实体。在此测试中,我创建了一个Brand希望返回的值,然后将 JSON 发布到控制器。最初,我依靠的是pass-by-reference我的控制器方法基本上是这样做的:

@Override
public ResponseEntity<MappingJacksonValue> save(@Valid @RequestBody Brand brand, BindingResult bindingResult) {

  validate(brand, null, bindingResult);
  if (bindingResult.hasErrors()) {
      throw new InvalidRequestException("Invalid Brand", bindingResult);
  }

  this.brandService.save(brand); // pass by reference
  MappingJacksonValue mappingJacksonValue = jsonView(JSON_VIEWS.SUMMARY.value, brand);
  return new ResponseEntity<>(mappingJacksonValue, HttpStatus.CREATED);
}
Run Code Online (Sandbox Code Playgroud)

请注意,我实际上并没有使用Brand从服务返回的内容。当我以这种方式测试时,我的测试失败了,因为控制器返回了我传入的 JSON,并且由于服务被模拟,控制器没有返回我期望的品牌,即有一个 ID。所以我改变了控制器来做到这一点:

brand = this.brandService.save(brand);
Run Code Online (Sandbox Code Playgroud)

但是,当我调试时,从模拟服务返回的品牌为空。下面是我的测试。

@RunWith(SpringRunner.class)
@WebMvcTest(BrandController.class)
public class BrandSimpleControllerTest {

  @Autowire
  private MockMvc mockMvc;

  @MockBean
  private BrandService brandService;

  @Test
  public void testSave() throws Exception {
    Brand brand = new …
Run Code Online (Sandbox Code Playgroud)

spring unit-testing mocking spring-boot

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