我已经有这个错误已经有将近一个星期了,我现在就准备好了.我已经使用Maven2制作了BIG jar文件.当我使用以下命令运行jar文件时:
java -jar someJar.jar
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
ERROR: [27/55/13 10:55] Launcher: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/context]
Offending resource: class path resource [JavaProjectApplicationContext.xml]
Run Code Online (Sandbox Code Playgroud)
JavaProjectApplicationContext.xml如下:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-3.0.xsd">
<bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location"><value>deployment.properties</value></property>
</bean>
<bean id="LexEditorDataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"><value>${hibernate.jdbc_driver}</value></property>
<property name="username"><value>${hibernate.username}</value></property>
<property name="password"><value>${hibernate.password}</value></property>
<property name="url"><value>${hibernate.url}</value></property>
<property name="defaultAutoCommit"><value>${hibernate.default_auto_commit}</value> </property>
<property name="maxActive"><value>20</value></property>
<property name="maxIdle"><value>3</value></property>
<property name="testOnBorrow"><value>true</value></property>
<property name="testOnReturn"><value>true</value></property>
<property name="testWhileIdle"><value>true</value></property>
</bean>
<context:component-scan base-package="com.k_int.bank.plugin">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Service"/> …Run Code Online (Sandbox Code Playgroud) 我在控制器中调用索引方法
def index() {
childInstance = Child.get(params.id)
if(childInstance){
System.out.println("CHILD" + childInstance.firstname)
def messages = currentUserTimeline()
[profileMessages: messages,childInstance:childInstance]
} else {
def messages = currentUserTimeline()
[profileMessages: messages]
System.out.println("ALL")
}
}
Run Code Online (Sandbox Code Playgroud)
在gsp页面中我有
${childInstance.firstname}
Run Code Online (Sandbox Code Playgroud)
如果我传递一个childInstance这很好但是如果我不这样做因为空指针而得到一个500是有一种方法我可以在gsp中做一个if语句所以我可以这样做
if(childInstance){
${childInstance.firstname}
} else {
All
}
Run Code Online (Sandbox Code Playgroud) 嗨,我试图从我的本地机器读取.json文件.它不会在我使用的代码中读取它:
jQuery.getJSON('../json/test.json')
.done(function(data) {
var test = data;
alert("sucsess");
})
.fail(function(data){
alert("failed");
});
Run Code Online (Sandbox Code Playgroud)
我所做的一切都失败了,我做错了什么.我没有通过这个服务器.
我试图在我的gsp中上传grails文件:
<g:form id="update" url="[action: 'updateStatus',]">
<g:textArea name="message" value="" cols="3" rows="1"/><br/>
<g:textField id="tagField" name="tag" value=""/><br/>
<input id="inputField" type="file" name="myFile" enctype="multipart/form-data" />
<g:submitButton name="Update Status"/>
</g:form>
Run Code Online (Sandbox Code Playgroud)
在我的控制器中我有:
def updateStatus(String message) {
if (params.myFile){
def f = request.getFile('myFile')
}
Run Code Online (Sandbox Code Playgroud)
请求获取文件失败,出现此错误:
No signature of method: org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestWrapper.getFile() is applicable for argument types: (java.lang.String) values: [myFile]
Run Code Online (Sandbox Code Playgroud)
任何想法为什么这就像我一样,并在我的其他控制器中使用getFile工作正常.
我正在做的是使用JSON创建一个表单,然后可以编辑该表单并生成新的JSON对象.我遇到的问题似乎是获取表单ID.我用来返回JSON对象的代码是:
form = document.forms[0];
$.fn.serializeObject = function()
{
alert("start serializeObject");
var o = {};
var a = this.seralizeArray();
$.each(a, function(){
if (o[this.name] !== undefined) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
} else {
o[this.name] = this.value || '';
}
});
return o;
alert(o);
};
$(function() {
alert("here");
form.submit(function(){
result.append(JSON.stringify(form.serializeObject()));
return false;
});
});
Run Code Online (Sandbox Code Playgroud)
这只是刷新页面我不知道为什么.此程序不在服务器上,不能在服务器上使用.通过这个我的意思是只有每一个都将在本地机器上本地运行,没有apache2设置.
谢谢.
我今天开始申请,当它开始时,我得到了这个错误
| 错误2012-09-14 13:54:17,608 [pool-7-thread-1]错误hbm2ddl.SchemaExport - 不成功:创建表顺序(默认情况下生成的id bigint为identity,version bigint not null,date_created timestamp not null,order varchar(255)not null,picture_id bigint not null,posts_id bigint not null,主键(id))
| 错误2012-09-14 13:54:17,609 [pool-7-thread-1]错误hbm2ddl.SchemaExport - SQL语句中的语法错误"CREATE TABLE ORDER [*](ID BIGINT由DEFAULT生成IDENTITY,VERSION BIGINT NOT NULL ,DATE_CREATED TIMESTAMP NOT NULL,ORDER VARCHAR(255)NOT NULL,PICTURE_ID BIGINT NOT NULL,POSTS_ID BIGINT NOT NULL,PRIMARY KEY(ID))"; 预期的"标识符"; SQL语句:创建表顺序(默认情况下生成的id bigint为identity,version bigint not null,date_created timestamp not null,order varchar(255)not null,picture_id bigint not null,posts_id bigint not null,primary key(id))[ 42001-164]
| 错误2012-09-14 13:54:17,621 [pool-7-thread-1]错误hbm2ddl.SchemaExport - 不成功:alter table order add constraint FK651874E9A8021F6 foreign key(posts_id)references …
我希望按日期对grails中的集合进行排序我目前正在执行以下操作:
def pics = Picture.findAllByChild(child, [sort: 'dateCreated', order: 'desc'])
pics.add(Post.findAllByPostedToAll(true))
Run Code Online (Sandbox Code Playgroud)
因为我已经在列表中添加了更多项目,我需要按dateCreated降序再次排序它看起来不像排序类可以做到这一点.我试过了:
pics.sort(it.dateCreated)
Run Code Online (Sandbox Code Playgroud)
但这是不允许的
嗨,我有一个名为ApiController的控制器,它使用一个名为ApiService的服务,如下所示:
def createCategory(){
def jsonObj = request.JSON
jsonObj.each{ key, value ->
params.put(key,value)
}
render apiService.createCategory(params)
}
Run Code Online (Sandbox Code Playgroud)
哪个工作正常.但我似乎无法为它编写测试.
这是我有多远:
@TestFor(ApiController)
@Mock([Category,ApiService])
class CategorySpec extends Specification {
def setup() {
}
def cleanup() {
}
void "test"() {
setup:
def apiService = Mock(ApiService)
when:
request.method = 'POST'
request.requestMethod = 'POST'
params.categoryID = 'test'
controller.createCategory()
then:
println(response)
1==1
}
Run Code Online (Sandbox Code Playgroud)
从这里我得到以下错误:
java.lang.NullPointerException: Cannot invoke method createCategory() on null object
Run Code Online (Sandbox Code Playgroud)
这显然是因为它无法看到我的apiService bean.所以我的问题是如何在Spock中做到这一点?
我试图通过dateCreated desc对集合进行排序,但我似乎无法做到这一点.
到目前为止我尝试了什么:
postOrder.sort({
dateCreated: 'desc'
})
postOrder.sort(dateCreated: 'asc')
Run Code Online (Sandbox Code Playgroud)
有任何想法吗??
我想有一个List的String在MySQL的作品在Grails领域类.
我尝试过以下方法:
class Catalogue {
List books
String book
static hasMany = [books: book]
}
Run Code Online (Sandbox Code Playgroud)
和
class Catalogue {
List books
}
Run Code Online (Sandbox Code Playgroud)
和
class Catalogue {
String[] books
}
Run Code Online (Sandbox Code Playgroud)
和
class Catalogue {
ArrayList<String> books = new ArrayList<String>()
}
Run Code Online (Sandbox Code Playgroud)
最后三个编译,但MySQL中没有该条目.在MySQL中没有用于表示此数据的表或列,我尝试使用数据填充数组.依然没有.
有任何想法吗?
grails ×7
javascript ×2
jquery ×2
json ×2
ddl ×1
grails-orm ×1
input ×1
sorting ×1
spock ×1
spring ×1
unit-testing ×1