我对 Grails 中的 withSession 和当前的休眠会话感到困惑。
我的问题是:我们在闭包中访问的会话对象是否与当前的休眠会话对象相同?
我编写了一个具有如下操作的服务:
def strangeBehavior(){
Link.withSession { session->
println "link current session " + session.hashCode()
}
Task.withSession { session->
println "task current session " + session.hashCode()
}
Project.withSession { session->
println "project current session " + session.hashCode()
}
UserStory.withSession { session->
println "user story current session " + session.hashCode()
}
def ctx = AH.application.mainContext
def sessionFactory = ctx.sessionFactory
def tmp = sessionFactory.currentSession
println " current session " + tmp.hashCode()
}
}
Run Code Online (Sandbox Code Playgroud)
对我来说奇怪的是,有 5 个不同的哈希码...如果我打印 5 …
我在Spring项目中遇到一个奇怪的错误,如下所示:
严重:servlet [calzoneServlet]的Servlet.service()在路径[/ calzone]的上下文中引发异常[请求处理失败; 嵌套异常是org.springframework.dao.InvalidDataAccessApiUsageException:Name不能为null或为空!嵌套异常是java.lang.IllegalArgumentException:名称不能为null或为空!!具有根本原因java.lang.IllegalArgumentException:Name不能为null或为空!
在这个项目中,所有模型都使用hibernate和jpa映射到数据库.前端使用Twitter Bootstrap(带弹簧形式验证等)
错误发生在程序的不同部分,其中一个是激活用户帐户的控制器(下面的代码).对我来说,这看起来像某种验证错误,但它不是我曾经定义的错误.由于我无法确定错误的确切位置,因此我将仅提供下面的控制器.值得注意的是,方法中的任何调试消息(无论是通过记录器还是仅仅是普通的旧sysout)activateUser都不会显示.
所有依赖项(pom.xml)都可以在这里找到:http: //pastebin.com/fs7SG0W2 Web.xml:http://pastebin.com/vAJh29Aw 整个堆栈跟踪可以在这里找到:http://codepad.org/p0Yt5hi2(在键盘上,因为它有水平滚动)
有没有人知道为什么会发生这种错误,或者有任何线索可以找出为什么会发生这种错误?
@Controller
public class ActivateAccountController {
final Logger logger = LoggerFactory.getLogger(getClass());
@RequestMapping(value = "/activate/{keyString}", method = RequestMethod.GET)
public String activateUser(@PathVariable String keyString) {
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
KeyService keyService = (KeyService) context.getBean("keyService");
UserService userService = (UserService) context.getBean("userService");
User user;
try {
logger.error("DID I GET HERE?");
user = keyService.findUserByKey(keyString);
} catch (KeyNotFoundException ex) {
return "ActivatedNotAccount";
} finally …Run Code Online (Sandbox Code Playgroud) 是否可以使用AWS CLI列出特定SQS队列已订阅的所有AWS SNS主题?
我已经知道如何查看SNS主题上的订户列表,但是仅当我知道SNS主题的名称时,该方法才有效。在这种情况下,我只知道SQS队列的名称。
我无法通过搜索互连网找到任何东西。
我正在尝试在我的域类中编写公式,这有助于我创建标准。
class MyClass {
//some fields
Date appointmentTime
String ddmmyy
int year
int month
int day
static transients = [
'ddmmyy',
'year',
'month',
'day'
]
static mapping= {
ddmmyy formula('DATE_FORMAT(appointmentTime)')
year formula('YEAR(appointmentTime)')
month formula('MONTH(appointmentTime)')
day formula('DAYOFMONTH(appointmentTime)')
}
}
Run Code Online (Sandbox Code Playgroud)
每当我尝试在我的标准中使用此字段时,它都会抛出错误,即无法解析“myClass”的属性“ddmmyy”。
我的标准是:
Date myDate = Calender.instance.time
def results = MyClass.createcriteria().list{
lt('appointmentTime', date+1)
ge('appointmentTime', date)
projections {
groupProperty('ddmmyy')
count('id')
}
}
Run Code Online (Sandbox Code Playgroud)
知道为什么我会因此获得例外吗?
grails grails-orm grails-domain-class grails-2.0 grails-services
Spring Boot有一个功能,它可以自动检测任何可用的日志框架(基于org.springframework.boot.logging.LoggingSystem.SYSTEMSLogback,Log4j或JUL中列出的类的存在),并从应用程序提供的日志配置文件或Spring Boot自己的默认配置文件进行配置,打包Spring Boot本身.
当将Grails 3应用程序作为war文件部署到JBoss EAP 6(又名WildFly 7)时,这会导致问题.当应用程序初始化时,Spring Boot会找到JBoss提供的JUL(org.jboss.logmanager.LogManager)日志记录实现,并调用readConfiguration()它上面的方法,这会影响日志记录配置.
有没有办法禁用Spring Boot的日志记录自动配置?(我可以使用Spring Boot 检测并使用日志框架;我只是不希望它尝试配置它.)我查看了源代码,但没有看到任何钩子来控制它.
相关源代码:
可能的想法:
LoggingApplicationListener从应用程序侦听器列表中删除它之前接收ApplicationStartedEvent或ApplicationEnvironmentPreparedEvent事件(触发日志记录的配置)?这些其他相关问题并没有解决我的问题,因为用例不同:
版本:
我在@ /下面有一个预配置的.vimrc文件,在通过'/'键搜索一个术语后,所有匹配的项目都会突出显示,但是在我找到需要位置并按下回车后,突出显示的术语仍然是高位的......它是非常令人失望,因为当我发出--c /" - 时,屏幕上有突出显示.它设置控制搜索突出显示设施?谢谢!
我正在寻找一种方法从命令行运行"生成控制器"为mavenized grails 2.1.0项目(即grails-maven-plugin 2.1.0).我尝试过以下方法:
mvn grails:generate-controller - 运行时我得到一个错误,说"java.lang.IllegalStateException:用户输入未启用,无法获取输入流".出于某种原因,grails似乎无法从控制台读取(以获取域类的名称).
mvn grails:exec "grails:generate-controller" - 这导致了一个 org.codehaus.groovy.grails.cli.ScriptNotFoundException有没有办法通过命令行参数指定域类的名称 - 即.类似的东西mvn generate-controller -DclassName=my.domain.class.name?
我是JPA的新手,当我尝试运行以下代码时,它显示错误为" cvc-elt.1:无法找到元素'持久性'的声明. "
我无法解决这个错误,请你帮我解决这个问题.
干杯
拉杰什
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1"
xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="jpa" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>com.optirisk.pojo.Department</class>
<class>com.optirisk.pojo.Employee</class>
<properties>
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.connection.username" value="NewsLetter1" />
<property name="hibernate.connection.password" value="optiindia2012" />
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/orpss_hibernate_prototype" />
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect" />
</properties>
</persistence-unit>
</persistence>
Run Code Online (Sandbox Code Playgroud)
public class Application {
private static final String PERSISTENCE_UNIT_NAME = "jpa";
private static EntityManagerFactory entityManagerFactory;
public static void main(String[] args) throws Exception {
entityManagerFactory = …Run Code Online (Sandbox Code Playgroud) 我有一个网络通知脚本,工作正常.但是当我在chrome版本43中测试时,我收到错误"DOMException:注册失败 - 权限被拒绝".订阅阶段发生此错误.
这是通常的注册过程的代码片段
navigator.serviceWorker.register('sw.js').then(function(reg) {
console.log('[ServiceWorker] Registration Obj', reg);
reg.pushManager.subscribe({
userVisibleOnly: true
}).then(function(sub) {
//This never executes and catch gets called
console.log('Subscription successful, Subscription endpoint:', sub.endpoint);
}).catch(function(error) {
console.log("Error during subscription ", error);
});
}).catch(function(error) {
if (Notification.permission === 'denied') {
console.warn('Permission for Notifications was denied');
} else {
console.error('Unable to subscribe to push.', error);
}
});
Run Code Online (Sandbox Code Playgroud)
在上面的代码中,错误发生在我执行的步骤中reg.pushManager.subscribe().
[注意]我认为它是铬版本43的一般问题但是当我检查像goroost.com和pushcrew这样的网站时,它们似乎工作正常.只有我的不工作
是否有一种简单的方法将a转换groovy.util.slurpersupport.Node为groovy.util.Node?
我试图XmlNodePrinter在一个节点上使用,来XmlSlurper进行一些快速调试.这是我的代码(可能不是最优雅的):
def xml = new XmlSlurper().parse( new File( path + pomFile ) )
def services = xml.build.plugins.plugin.configuration.services
services.children().findAll{ it.artifactId.text() == serviceName }.each { config ->
// begin section to dump "config" for debugging
def stringWriter = new StringWriter()
new XmlNodePrinter(new PrintWriter(stringWriter)).print(config[0])
println stringWriter.toString()
// end section to dump "config" for debugging
// do some other processing on the config node
}
Run Code Online (Sandbox Code Playgroud)
这会抛出以下内容config[0]:
org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'groovy.util.slurpersupport.Node@14712c3' with class …Run Code Online (Sandbox Code Playgroud) grails ×3
hibernate ×3
jpa ×2
maven ×2
amazon-sns ×1
amazon-sqs ×1
grails-2.0 ×1
grails-orm ×1
groovy ×1
javascript ×1
jpa-2.0 ×1
jta ×1
session ×1
spring ×1
spring-boot ×1
spring-data ×1
vim ×1
web-push ×1
xml ×1