我想创建一个使用参数创建的原型...坚果我不知道这是否是一个以这种方式制作的参数:
<requiredProperties>
<requiredProperty key="appName">
<defaultValue>${artifactId}</defaultValue>
</requiredProperty>
</requiredProperties>
Run Code Online (Sandbox Code Playgroud)
这对我不起作用......我在集成测试中失败了
[INFO] --- maven-archetype-plugin:2.0:integration-test (default-integration-test) @webapp-archetype ---
[ERROR] Archetype test.archetype:webapp-archetype:1.0-SNAPSHOT is not configured
Property appName is missing.
org.apache.maven.archetype.exception.ArchetypeNotConfigured: Archetype test.archetype:webapp-archetype:1.0-SNAPSHOT is not configured
Property appName is missing.
我有一个多项目gradle构建,以这种方式配置:
root
|
|---- projectA
|
|---- projectB
Run Code Online (Sandbox Code Playgroud)
我想在root/build.gradle所有嵌套项目的依赖项中声明,这是文件:
subprojects {
version = '1.0-SNAPSHOT'
repositories {
mavenLocal()
mavenCentral()
maven {
url 'https://repository.jboss.org/nexus/content/groups/public-jboss/'
}
}
}
allprojects {
dependencies {
compile 'org.projectlombok:lombok:1.12.2'
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我执行构建时,我有:
* What went wrong:
Run Code Online (Sandbox Code Playgroud)
评估根项目"代码"时出现问题.
No signature of method:
org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.compile() is applicable for argument types: (java.lang.String) values: [org.projectlombok:lombok:1.12.2]
Run Code Online (Sandbox Code Playgroud)
可能的解决方案:module(java.lang.Object)
我做错了什么?
我必须使用hibernate并且不太确定如何解决这个问题,我有2个表,其中有一个1..n关系,如下所示:
------- TABLE_A ------- first_id (pk) second_id (pk) [other fields] ------- TABLE_B ------- first_id (pk)(fk TABLE_A.first_id) second_id (pk)(fk TABLE_A.second_id) third_id (pk) [other fields]
如何使用Hibernate管理它?
我不知道如何管理第二个表的主键...
我在我的Grails控制器中有一个方法应该返回一个JSON,JSON的一个属性是一个Date对象,但是当我这样做时:
render myObject as JSON
Run Code Online (Sandbox Code Playgroud)
输出如下:
{
"dateProperty": "2010-12-31T23:00:00Z",
"otherProperty" : "aValue..."
}
Run Code Online (Sandbox Code Playgroud)
有没有办法更改转换器使用的默认日期格式?
我试图设置属性grails.converters.json.date,并grails.date.formats在Config.groovy中,但这行不通.
我做错了什么或有其他方法吗?
谢谢
我是领域驱动设计的新手,我对一些概念有所怀疑(希望这是一个正确的问题).
我知道在DDD我应该避免贫血模型,所以考虑一个社交网络模型谁应该(保存)两个朋友之间的友谊?
我想象有一个代表用户的类(使用类似Java的语法)的情况:
class User{
String username
List<User> friends
}
Run Code Online (Sandbox Code Playgroud)
那么,它应该有一个添加朋友的方法
class User{
void friendship(User friend)
}
Run Code Online (Sandbox Code Playgroud)
或者我应该使用服务吗?
class UserService{
void friendship(User user, User user2)
}
Run Code Online (Sandbox Code Playgroud) 在应用程序上下文中,我已经注册了一个ObjectMapper模块:
@Bean
public SimpleModule jsr310Module() {
final SimpleModule module = new SimpleModule();
module.addSerializer(new LocalDateSerializer());
module.addDeserializer(LocalDate.class, new LocalDateDeserializer());
return module;
}
Run Code Online (Sandbox Code Playgroud)
我试图调试并加载它(或者至少方法public void setupModule(SetupContext context)是在启动时执行)但是当我调用一个返回带有LocalDate的对象的rest API时,我的反序列化器被忽略.
有些提示可以解决问题吗?
我正在写一个标准来进行查询,但我无法弄清楚如何否定inList标准......有没有办法做类似的事情:
def result = c {
not inList('id', ids)
}
Run Code Online (Sandbox Code Playgroud)
谢谢
我知道在Java中,当你的情况很少时,不应该使用switch语句,在这种情况下,最好使用一个if else if.
对于groovy来说也是如此吗?
哪个在这两个代码之间更高效?
myBeans.each{
switch it.name
case 'aValue':
//some operation
case 'anotherValue:
//other operations
}
Run Code Online (Sandbox Code Playgroud)
要么:
myBeans.each{
if(it.name == 'aValue'){
//some operation
}
else if (it.name =='anotherValue){
//other operations
}
}
Run Code Online (Sandbox Code Playgroud) 我想创建一个简单的列表,当用户点击一个按钮时,该值显示在span元素中.
HTML和控制器
<html xmlns:ng="http://angularjs.org">
<script src="http://code.angularjs.org/angular-0.9.19.js" ng:autobind></script>
<script type="text/javascript">
function MyController(){
this.list = [{name:"Beatles", songs: ["Yellow Submarine", "Helter Skelter", "Lucy in the Sky with Diamonds"]}, {name:"Rolling Stones", songs:["Ruby Tuesday", "Satisfaction", "Jumpin' Jack Flash"] }]
this.songs = [];
}
</script>
<body ng:controller="MyController">
<p>selected: <span ng:bind="selected" ng:init="selected='none'" /></p>
<ul>
<li ng:repeat="artist in list">
<button ng:click="selected = artist.name" >{{artist.name}}</button>
</li>
</ul>
<!--ol>
<li ng:repeat="song in songs">
{{song}}
</li>
</ol-->
</body>
Run Code Online (Sandbox Code Playgroud)
我想动态显示被点击的艺术家的歌曲列表.这是正确的方法吗?
有没有办法使用元类对象替换,这是一个超类的方法.例:
class A {
def doIt(){
two()
println 'do it!'
}
protected two(){
println 'two'
}
}
class B extends A{
def doLast(){
doIt()
}
}
B b = new B();
b.doIt()
/*
* two
* doit!
*/
b.metaClass.two = {
println 'my new two!'
}
b.doIt();
/*
* my new two!
* do it!
*/
Run Code Online (Sandbox Code Playgroud) grails ×2
groovy ×2
angularjs ×1
converter ×1
criteria ×1
date ×1
dependencies ×1
foreign-keys ×1
gradle ×1
grails-orm ×1
hibernate ×1
jackson ×1
javascript ×1
jodatime ×1
json ×1
maven ×1
metaclass ×1
performance ×1
spring-boot ×1