目前我们有一个通过在Tomcat context.xml文件中使用数据源配置的应用程序.因此,我们可以通过检索JNDI名称并获得连接来成功获得连接.我想知道我们是否可以通过使用Spring数据源替换它,如果我们仍然需要context.xml文件中的信息?
示例'context.xml':
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Resource
name="jdbc/myDataSource"
auth="Container"
type="javax.sql.DataSource"
username="john"
password="doe"
driverClassName="<removed>"
url="<removed>"
maxActive="30"
maxIdle="10"
maxWait="1000"
removeAbandonedTimeout="60"
removeAbandoned="true"
logAbandoned="true"/>
</Context>
Run Code Online (Sandbox Code Playgroud)
所以在我们的代码中,我们搜索这样的JNDI上下文:
Context envCtx = (Context) initCtx.lookup(..);
DataSource ds = (DataSource) envCtx.lookup(..);
Connection connection = ds.getConnection();
Run Code Online (Sandbox Code Playgroud)
我想知道我们是否可以更好地定义Spring数据源而不是使用这种方法以及我们如何做到这一点?
Spring数据源和Tomcat数据源有什么区别?任何专业人士/骗子?有偏好的选择吗?
我正在使用MyBatis,并希望在每个"创建","修改"的表上实现2个字段.它们都是日期字段.有没有办法在插入或更新时自动更新这些字段?幕后我可以调整映射,但我想知道是否有更通用和干的方式这样做?
我试图得到一个情况,我可以使用i18n属性文件备份数据库?
所以对于一些标准的东西,我想使用属性文件,但有些字段必须是最终用户可编辑的,所以我打算在数据库中使用i18n.所以真正的组合会很棒.如果在属性文件中找不到i18n代码,则在DB中进行查找.
知道如何解决这个问题吗?我已经看过Grails i18n从数据库发布但默认返回文件
但问题没有真正的答案,还有其他任何关于如何解决这个问题的建议?
我创建了一个多模块maven项目,我正在尝试编写和执行特定模块的一些测试.我试图将所有测试代码放入一个单独的模块,但我想知道这是否是正确的方法,如果是这样,我如何设置maven构建/测试周期,所以mvn安装将使用这些测试?
我试图在我的应用程序中使用tomcat jdbc-pool,但似乎我找不到提供此依赖项的存储库.我可以在哪个存储库找到可以在Maven构建中使用的最新版本的任何线索?
我正在使用IntelliJ开发Grails应用程序,但随着我们的应用程序的增长,我在使用Tomcat插件时遇到了Permgen错误.我在permgen设置中尝试了几种组合,但它们似乎没有任何效果.
处理这些Permgen错误的任何解决方案?
我需要生成特定布局的pdf文件,支持多个pdf页面等.我可以想象我可以将gsp输出渲染为pdf,但我如何处理多个页面的概念?有什么建议吗?
我试图将一些数据绑定到作为命令对象一部分的对象.尝试使用它时,该对象保持为null.可能我没有在gsp中给出正确的数据,但我不知道我做错了什么!
我希望当我提交一个带有字段名称'book.title'的表单时,这将被映射到命令对象..但是这会失败..标题保持[null]
每当我更改命令对象和表单以使用字符串标题作为属性它工作..
// the form that submits the data
<g:form>
<g:textField name="book.title" value="Lord Of the Rings"/><br>
<br><br>
<g:actionSubmit action="create" value="Create!"/>
</g:form>
// the controller code
def create = { BooksBindingCommand cmd ->
println cmd?.book?.title // the book property always stays null
redirect(action: "index")
}
// the command object
class BooksBindingCommand {
Book book
}
// the book class, simple plain groovy class
class Book {
String title
}
Run Code Online (Sandbox Code Playgroud)
关于为什么'book.title'的绑定失败的任何建议?
在我们当前的应用程序中,我们需要遍历树并捕获特定设备(和子设备)上的所有操作员。设备可以具有子设备,并且子设备上还具有特定的操作员。
由于我对 Groovy 中的递归使用不熟悉,我想知道我做的事情是否正确..?有什么建议可以帮助我学习更好的做事方法吗?
def listOperators(device) {
// list with all operator id's
def results = []
// closure to traverse down the tree
def getAllOperators = { aDevice->
if(aDevice) {
aDevice.operators.each { it ->
results << it.id
}
}
if (aDevice?.children) {
aDevice.children.each { child ->
results << owner.call(child)
}
}
}
// call the closure with the given device
getAllOperators(device)
// return list with unique results
return results.unique()
}
Run Code Online (Sandbox Code Playgroud) 我正在使用 Jasper 插件,并且想在导出到 Excel 时禁用白色背景。我怎样才能做到这一点?
/马可