Код: Выделить всё
package com.mycompany.myapp
class BootStrap {
def init = {
def adminRole = new Role(authority: 'ROLE_ADMIN').save()
def testUser = new User(username: 'me', password: 'password').save()
UserRole.create testUser, adminRole
UserRole.withSession {
it.flush()
it.clear()
}
assert User.count() == 1
assert Role.count() == 1
assert UserRole.count() == 1
}
}
2020-03-31 15:46:19.294 ERROR --- [ restartedMain]
o.s.boot.SpringApplication
: Application run failed
javax.persistence.TransactionRequiredException: no transaction is in
progress
at org.hibernate.internal.SessionImpl.checkTransactionNeeded(SessionImpl
.java:3586)
I've attempted to use @Transactional to solve Это, но это не повлияло на ошибку. ВОЗВРАТИТЕЛЬНАЯ Bootstrap.groovy к своему по умолчанию позволяет приложению работать нормально. Что не хватает (или неправильно) из этого учебника, который заставляет его терпеть неудачу?
Подробнее здесь: https://stackoverflow.com/questions/609 ... curity-cor