小编Ano*_*man的帖子

Integer上的isNumber()引发错误

这个错误是否意味着我正在调用isNumber()null值?我似乎无法理解它.

No signature of method: 
java.lang.Integer.isNumber() is applicable for argument types: () values: []. 

Stacktrace follows:
Message: No signature of method: 
java.lang.Integer.isNumber() is applicable for argument types: () values: []
Run Code Online (Sandbox Code Playgroud)

groovy

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

Groovy方法重载

我有两个域类,我想在我的服务中运行一个方法.服务的方法将对两个对象执行非常类似的操作,并且它使用的那些对象中的属性在两个具有相同名称的对象中.所以,而不是像这样做两个方法:

calculateTotalBalancesInd(IndividualRecord indRec) {
     //do something with indRec.accountsList
}
calculateTotalBalancesEnt(EntityRecord entRec) {
     //do something with entRec.accountsList
}
Run Code Online (Sandbox Code Playgroud)

是否有一种巧妙的方法(重载?)来制作一个可以对任何一个对象进行操作的方法?

谢谢

grails groovy

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

Spring Boot应用程序可以通过Maven运行,但不能通过IDE Intellij IDEA运行

我有一个弹簧启动应用程序,通过Maven的mvn spring-boot:run命令运行良好.但是,当我尝试通过IDE(在我的情况下是Intellij IDEA 2017.2.1)中运行它时,它失败了,因为它不能@Autowire是数据源.

***************************
APPLICATION FAILED TO START
***************************

Description:

Parameter 0 of constructor in com.myApp.Application required a bean of type 'javax.sql.DataSource' that could not be found.


Action:

Consider defining a bean of type 'javax.sql.DataSource' in your configuration.
Run Code Online (Sandbox Code Playgroud)

这个代码库的原始作者有主类,它启动应用程序,接受数据源的构造函数参数,这是我不熟悉的方法,因为我习惯于通过application.properties文件执行它并让Spring Boot连接它自己的数据源.

@EnableTransactionManagement
@SpringBootApplication
@EnableCaching
public class Application extends JpaBaseConfiguration {


    protected Application(DataSource dataSource, JpaProperties properties,
            ObjectProvider<JtaTransactionManager> jtaTransactionManagerProvider,
            ObjectProvider<TransactionManagerCustomizers> transactionManagerCustomizers) {
        super(dataSource, properties, jtaTransactionManagerProvider, transactionManagerCustomizers);
    }
Run Code Online (Sandbox Code Playgroud)

在IDEA中,我注意到这个构造函数datasourceproperties参数和红色下划线.对于datasourceIDE的抱怨两个豆存在,它不知道这之间自动装配XADataSourceAutoConfiguration.class和 …

spring intellij-idea maven spring-boot

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

Groovy列表排序有两个标准

我有一个对象列表,它们都是相同的类型,有两个属性'uniqueId'和'secondaryId'.我想先为'uniqueId'排序此列表,然后为每个uniqueId排序'secondaryId',以便此列表:

UniqueID/SecondaryID 5/3 2/6 5/8 2/5

一旦排序将看起来像:2/5 2/6 5/3 5/8

我似乎无法正确地得到语法:

return searchResults.sort{[it.uniqueId, it.secondaryId]}
Run Code Online (Sandbox Code Playgroud)

是我想要开始,但这不起作用.

grails groovy

0
推荐指数
1
解决办法
818
查看次数

Grails无法保存对象

我试图将对象保存到我的数据库时得到一个相当奇怪的错误.在尝试保存基类对象时,代码已经完成了,但现在我正在尝试保存从基类域继承的域类.

这是父类:

package com.twc.fatcaone

class Record {

long batchID

}
Run Code Online (Sandbox Code Playgroud)

和我想要保存的子类:

package com.twc.fatcaone

class AccountRecord extends Record {

    long uniqueId
    String accountId
    String type
    String insurance
    String currencyType
    float amount
    String upSerDel
    String generalComments

    static mapping = {
        collection "accountRecords"
        database "twcdb"
}
}
Run Code Online (Sandbox Code Playgroud)

我的服务中的代码正在尝试进行保存:

accountRecordList.each { 

                def accountRecord = new AccountRecord(batchID: params.selectedBatch.id,
                                                        uniqueId: it.uniqueId,
                                                        accountId: it.accountId,
                                                        type: it.type,
                                                        insurance: it.insurance,
                                                        currencyType: it.currencyType,
                                                        amount: it.amount,
                                                        upSerDel: it.upSerDel,
                                                        generalComments: it.generalComments)

                       if (!AccountRecord.save(flush: true, failOnError: true)) {
                           println "ERROR: Record could not …
Run Code Online (Sandbox Code Playgroud)

grails hibernate

-1
推荐指数
1
解决办法
582
查看次数

标签 统计

grails ×3

groovy ×3

hibernate ×1

intellij-idea ×1

maven ×1

spring ×1

spring-boot ×1