小编Ant*_*Dev的帖子

从Groovy中的URL解析JSON对象

我正在尝试将以下API中的JSON对象解析为groovy:

http://mtgapi.com/api/v1/fetch/id/1?token=f1fc6636e6f25d97c007984f0c7fe5785b3e3482

这是我的班级:

package mtgtournamentorganizer

import groovy.json.JsonSlurper

class GetCardService {

    String token = "?token=f1fc6636e6f25d97c007984f0c7fe5785b3e3482"
    String base = "http://mtgapi.com/api/v1/fetch/"
    String id = "id/"
    String cardId
    String apiString

    def getCardById(cardId) {

        apiString =base + id + cardId + token

        URL apiUrl = new URL(apiString)

        def card = new JsonSlurper().parse(apiUrl)

        return card

    }

}
Run Code Online (Sandbox Code Playgroud)

我打电话的时候 getCardById(1)

我收到此错误:

|  groovy.lang.MissingMethodException: No signature of method: groovy.json.JsonSlurper.parse() is applicable for argument types: (java.net.URL) values: [http://mtgapi.com/api/v1/fetch/id/1?token=f1fc6636e6f25d97c007984f0c7fe5785b3e3482]
Possible solutions: parse(java.io.Reader), use([Ljava.lang.Object;), wait(), any(), grep(), wait(long)
    at mtgtournamentorganizer.GetCardService.getCardById(GetCardService.groovy:21)
Run Code Online (Sandbox Code Playgroud)

grails groovy json

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

Alamofire请求的多种编码类型

我需要POST使用带有JSON对象的HTTP Body发出请求,但我还需要在同一请求中使用url查询参数.

POST: http://www.example.com/api/create?param1=value&param2=value
HTTP Body: { foo : [ bar, foo], bar: foo}
Run Code Online (Sandbox Code Playgroud)

这是否受到Alamofire的支持?我该怎么做呢?

alamofire

9
推荐指数
1
解决办法
2612
查看次数

MappingException:无法确定Type

在这里获取Hibernate MappingException,我无法弄清楚原因.

这是我得到的错误:

2014/01/13 23:58:38 [] ERROR GrailsContextLoader  - Error initializing the application: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException: Could not determine type for: com.apporder.User, at table: user_check_in_definition, for columns: [org.hibernate.mapping.Column(user)]
org.springframework.beans.factory.BeanCreationException: Error creating bean with …
Run Code Online (Sandbox Code Playgroud)

grails hibernate grails-orm

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

方法在Grails应用程序之外使用

当我在我的域类上使用保存操作时,我收到一条带有以下错误的flash消息:

Method on class [com.xxxxxxx.Detail] was used outside of a Grails application.
 If running in the context of a test using the mocking API or bootstrap Grails correctly.
Run Code Online (Sandbox Code Playgroud)

运行Grails 2.3.7和Hibernate应该更新得很好.我的引导工作正常,我能够在其中保存域类实例.但是当我尝试从开发环境中保存Detail类实例时,我收到此错误.

为什么我收到此错误?有任何想法吗?

谢谢!

BuildConfig.groovy包含:

dependencies {
        build "com.google.gwt:gwt:2.5.1"
        compile 'org.ccil.cowan.tagsoup:tagsoup:1.2'
        compile "org.apache.solr:solr-solrj:4.6.1"
        compile "commons-dbcp:commons-dbcp:1.4"
        runtime  'org.postgresql:postgresql:9.3-1100-jdbc41'
        compile "ar.com.fdvs:DynamicJasper:5.0.0"

    }

    plugins {
        // Java 6.0 has this already
        runtime(':mail:1.0') { excludes 'mail', 'activiation', 'spring-test' }

        runtime ":hibernate:3.6.10.10"
        build ":tomcat:7.0.52.1"
        compile ":smartgwt:0.2"
        build ":extended-dependency-manager:0.5.5"
        compile ":gwt:1.0", {
            transitive=false

        }
        compile ":cxf:1.1.1"

        compile ":executor:0.3" …
Run Code Online (Sandbox Code Playgroud)

grails groovy hibernate

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

单元测试与集合视图流布局上的estimatedItemSize崩溃 - EXC_ARITHMETIC

我有一个UICollectionViewFlowLayout具有estimatedItemSize集.

当我运行我的应用程序时,一切正常,但在我的单元测试中,EXC_ARITHMETIC每次击中我都会崩溃collectionView:dequeueReusableCellWithReuseIdentifier:.

我知道这是因为我estimatedItemSize删除它修复了崩溃.

有谁知道为什么会这样?

谢谢

unit-testing ios uicollectionviewlayout

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

具有非可选属性的类符合具有可选属性的协议

如果我有一个具有可选属性的协议,以及一个需要符合具有相同属性的协议的类,但作为非可选属性,我该如何使该类符合该协议.

protocol MyProtocol {
    var a: String? { get set }
}

class MyClass {
    var a: String
}

extension MyClass: MyProtocol {
    // What do I put here to make the class conform
}
Run Code Online (Sandbox Code Playgroud)

swift

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

Grails Controller Actions可能不会超载

我正在尝试使用重载方法在Grails 2.3.4中的控制器中附加XML.

我在ReportController中有以下重载方法.

String makePhotoXml(StringBuilder sb, Report r, String url, String desc) {

    sb.append("<photo>")
    sb.append(Utilities.makeElementCdata("url", url))
    sb.append(Utilities.makeElementCdata("caseId", r.caseId))
    sb.append(Utilities.makeElementCdata("type", r.type))
    sb.append(Utilities.makeElementCdata("date", r.dateCreated.format('MM/dd/yy')))
    sb.append(Utilities.makeElementCdata("address", r.address))
    sb.append("<extra>extra</extra>")
    sb.append(Utilities.makeElementCdata("description", desc))
    sb.append("</photo>")
}

String makePhotoXml(List<Report> reports) {
    StringBuilder sb = new StringBuilder()
    sb.append("<photos>")
    sb.append("<title>Photos</title>")
    for (Report r : reports) {
        for (Photo photo : r.photos) {
            makePhotoXml(sb, r, photo.url(), photo.description)
        }
        for (Document doc : r.photoDocuments) {
            makePhotoXml(sb, r, doc.url(-1), doc.getDescription())
        }
    }
    sb.append("</photos>")
}
Run Code Online (Sandbox Code Playgroud)

运行应用程序时,我收到此编译器错误:

| Error Compilation error: startup failed:
/Users/Anthony/GrailsApps/AppOrderWeb/grails-app/controllers/com/apporder/ReportController.groovy: 1360: …
Run Code Online (Sandbox Code Playgroud)

grails groovy

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

使用私有框架的应用程序"无法检查Xcode 6中的应用程序包".缺少框架info.plist

我的应用程序在Xcode 5中构建并运行得很好.我昨天升级到Xcode 6,现在应用程序构建,但不会在我的设备或模拟器中运行.

我在尝试运行时收到错误"无法检查应用程序包".

我检查了我的设备日志(XCode> Windows>设备),在尝试运行应用程序后,我在日志中收到以下错误:

9月23日10:32:46 XXXXXX-iPhone streaming_zip_conduit [5476]:__ dispisp_source_read_socket_block_invoke:203:无法在file:///var/mobile/Media/PublicStaging/ActivateMachines.app/安装应用程序:Error Domain = LaunchServicesError Code = 0"操作无法完成.(LaunchServicesError错误0.)"UserInfo = 0x1355075a0 {Error = PackageInspectionFailed,ErrorDescription =无法从路径/private/var/mobile/Library/Caches/com.apple上的bundle加载Info.plist. mobile.installd.staging/temp.5lz5TS /提取/ ActivateMachines.app /框架/ GeLoSDK.framework}

我已经检查过GeLoSDK.framework确实有一个Resources/Info.plist文件.

我正在使用这个框架:https: //github.com/GeLoInc/GeLoSDK-iOS

它应该正确链接,因为它正在使用Xcode 5.

我不知道Xcode 6中有什么变化吗?谢谢你的帮助.

iphone xcode ios xcode6

4
推荐指数
2
解决办法
6608
查看次数