gpt4 book ai didi

grails - 使用审计日志插件在 grails 中插入双记录

转载 作者:行者123 更新时间:2023-12-04 12:41:03 25 4
gpt4 key购买 nike

我已经安装了 audit-logging插件到我的应用程序。 grails 版本是 2.1.1插件版本是1.0.1 .

在我的 Config.groovy类,我添加了这个

auditLog {
verbose = true // verbosely log all changed values to db
logIds = true // log db-ids of associated objects.
// Note: if you change next 2 properties, you must update your database schema!
tablename = 'audit_logs' // table name for audit logs.
transactional = false
actorClosure = { request, session ->
org.apache.shiro.SecurityUtils.getSubject()?.getPrincipal()
}

在我的域类中我添加了这个
class Survey {
static auditable = true
static final int NO_RUNNING_SURVERY = 0
static final int RUNNING_SURVERY = 1

static final int CALL_NO_Record_SURVEY = 0
static final int CALL_Record_SURVEY = 1

static final int REALTIME_SURVEY = 0
static final int HISTORICAL_SURVEY = 1
static final int STANDARD_SURVERY = 2

String name
String description
int status
}

当我添加、删除和更新某些东西时。
在我的 audit_logs表,针对一项操作插入双记录,例如
如果我从 Controller 类更改状态值
def stopSurvey(Long id) {
def survey = Survey.findById(params['stop'])
survey.status = Survey.NO_RUNNING_SURVERY


redirect(action: "list")
}

它每次调用插入两条记录。

最佳答案

@Bertl

我找到了问题,我想,问题出在插件上。我的应用程序使用三个数据库,一个是主数据库,另外两个用于其他目的。我的数据源如下。

dataSource.driverClassName = net.sourceforge.jtds.jdbcx.JtdsDataSource
dataSource.dbCreate = update
dataSource.url = jdbc:jtds:sqlserver://localhost:1433/test
dataSource.username = test
dataSource.password = 123

#TEST1
dataSource_TEST1.driverClassName = net.sourceforge.jtds.jdbcx.JtdsDataSource
dataSource_TEST1.readOnly = true
dataSource_TEST1.url = jdbc:jtds:sqlserver://xxx.xxx.xxx.xxx:1433/test1
dataSource_TEST1.username = test1
dataSource_TEST1.password = 123


# TEST2
dataSource_TEST2.driverClassName = net.sourceforge.jtds.jdbcx.JtdsDataSource
dataSource_TEST2.readOnly = true
dataSource_TEST2.url = jdbc:jtds:sqlserver://xxx.xxx.xxxx.xxx:1433/test2
dataSource_TEST2.username = test2
dataSource_TEST2.password = 123

当我只使用 test数据源并删除其他 dataSources ,它插入一条记录。当我使用两个数据源时,它会在 audit logging 中插入两个记录 table 。
与我使用三个数据源时相同,然后它在审计日志中插入三个记录。
我需要所有三个数据库,但它会产生问题。我现在该怎么办?

关于grails - 使用审计日志插件在 grails 中插入双记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24241355/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com