我正在开发一个grails插件,但是当我尝试为服务创建集成测试时,我遇到了这个错误
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'aService': Cannot resolve reference to bean 'transactionManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'transactionManager' is defined
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:232)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:61)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:223)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:29)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.junit.runners.Suite.runChild(Suite.java:129)
at org.junit.runners.Suite.runChild(Suite.java:24)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:232)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:61)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:223)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at _GrailsTest_groovy$_run_closure4.doCall(_GrailsTest_groovy:290)
at _GrailsTest_groovy$_run_closure2.doCall(_GrailsTest_groovy:249)
at _GrailsTest_groovy$_run_closure1_closure21.doCall(_GrailsTest_groovy:195)
at _GrailsTest_groovy$_run_closure1.doCall(_GrailsTest_groovy:184)
at TestApp$_run_closure1.doCall(TestApp.groovy:82)
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: …Run Code Online (Sandbox Code Playgroud) 我有一个关于g:render和g:include的优点和缺点的问题.在我的应用程序中,我有一段代码,显示了一些必须在某些gsp中重复的信息,它显示的内容取决于一些逻辑.
我怀疑是否更好地使用g:include或g:render ???
那么,在将模型传递给使用g:render附带的布局的页面的控制器上执行逻辑是否更好,或者最好将ag:include放到执行gsp的另一个控制器中的另一个操作中那件作品的逻辑?
我更喜欢第二种选择,但它对性能有多大影响?
我对 Node.js 还很陌生,我必须编写一个必须使用 Oracle 数据库的应用程序。
我发现这个 ORM 连接到 Oracle 数据库https://github.com/nearinfinity/node-persist但 Oracle 的文档非常差。
有人知道是否有更好的解决方案或有一些使用 Oracle 管理模块的示例?
谢谢
我想根据用户的角色在我的角度应用程序中注册路由,我可以这样做:
angular.module('myModule', [])
.config(function($routeProvider, $http){
$routeProvider.when('/home',{
templateUrl: '/home.html',
controller: 'HomeCtrl'
});
$http.get('/user')
.success(function(user){
if (user.admin){
$routeProvider.when('/dashboard, {
templateUrl: '/dashboard.html',
controller: 'DashboardCtrl'
});
}
});
});
Run Code Online (Sandbox Code Playgroud)
但是在config方法中我无法使用该$http服务,我该如何实现呢?
我不太清楚在Scala中部分应用函数...我会做一个例子:
def myOperation(x: Int)(y: Int): Int = {
val complexVal = complexCalc(x)
println("complexVal calculated")
complexVal + y
}
def complexCalc(x: Int): Int = x * 2
val partial = myOperation(5)_
println("calculate")
println("result(3): " + partial(3))
println("result(1): " + partial(1))
Run Code Online (Sandbox Code Playgroud)
这个输出将是:
calculate
complexVal calculated
result(3): 13
complexVal calculated
result(1): 11
Run Code Online (Sandbox Code Playgroud)
所以complexVal计算了2次,如果我只计算一次呢?
对于谁有javascript知识的东西:
function myOperation(x) {
var complexVal = complexCalc(x)
return function(y){
complexVal + y
}
}
Run Code Online (Sandbox Code Playgroud)
编辑:
那么我之前写的和之间的区别是什么:
def myOperation2(x: Int, y: Int): Int = { …Run Code Online (Sandbox Code Playgroud) 我想知道为什么在Java8 API上Optional类有方法ifPresent(Consumer< T> consumer)而不是ifNotPresent(Runnable** consumer)?
API的目的是什么?是不是模仿功能模式匹配?
**Java没有零参数void功能接口...
随着课程:
public class Person {
private String name;
private Color favouriteColor;
}
public enum Color {GREEN, YELLOW, BLUE, RED, ORANGE, PURPLE}
Run Code Online (Sandbox Code Playgroud)
有一个List<Person>我使用Java8流API可以trasform它在Map<Color, Long>其每个计数Color,也未包括在列表中的颜色.例:
List<Person> list = List.of(
new Person("Karl", Color.RED),
new Person("Greg", Color.BLUE),
new Person("Andrew", Color.GREEN)
);
Run Code Online (Sandbox Code Playgroud)
在地图中使用枚举的所有颜色及其计数来转换此列表.
谢谢
解决了
使用自定义收集器解决:
public static <T extends Enum<T>> Collector<T, ?, Map<T, Long>> counting(Class<T> type) {
return Collectors.toMap(
Function.<T>identity(),
x -> 1l,
Long::sum,
() -> new HashMap(Stream.of(type.getEnumConstants()).collect(Collectors.toMap(Function.<T>identity(),t -> 0l)))
);
}
list.stream()
.map(Person::getFavouriteColor)
.collect(counting(Color.class))
Run Code Online (Sandbox Code Playgroud) 如果我有两个休眠实体,例如:
@Entity
class Company {
@Id
Integer id;
String name;
}
@Entity
class Person {
Integer id;
String name;
@ManyToOne
Company company;
}
Run Code Online (Sandbox Code Playgroud)
我有一个已经存储的公司,例如Company(id:1, name:"Acme")
我可以创建一个仅使用公司 ID 来引用该公司的人员,而不是加载整个记录,例如:
Session session = SessionFactory.openSession();
Company acme = new Company();
acme.setId(1);
Person person = new Person();
person.setName("Manuel");
person.setCompany(acme);
session.save(person);
Run Code Online (Sandbox Code Playgroud)
它只保存参考,还是还用 更新公司name=null?
我有一个简单的 POST 请求发送参数使用 application/x-www-form-urlencoded编码。
查看wiremock docs我找不到通过params值匹配请求的方法,例如querystring我的意思匹配。
此外,似乎也不可能 contains身体进行匹配,清晰的方式匹配整个身体(就像 base64 一样)。
有没有办法匹配这种请求?
我有以下 json:
{
"first": {
"second" : "A"
},
"array": [
{
"name" : "AAA",
"something": {
"hola": "hi"
}
},
{
"name" : "BBB",
"something": {
"hola": "hi"
}
}
]
}
Run Code Online (Sandbox Code Playgroud)
我想对其进行转换,使用父级属性的something值向对象添加属性,例如:name
我有以下 json:
{
"first": {
"second" : "A"
},
"array": [
{
"name" : "AAA",
"something": {
"hola": "hi",
"NEW_PROPERTY": "AAA"
}
},
{
"name" : "BBB",
"something": {
"hola": "hi",
"NEW_PROPERTY": "BBB"
}
}
]
}
Run Code Online (Sandbox Code Playgroud)
哪个 jq 表达式可以做到这一点?