我试图将基于xml的Spring MVC应用程序移动到基于Java配置的应用程序.似乎与maven中可用的各种java.servlet类不匹配.例如,有些提供addServlet()方法,有些则不提供.
这是我的配置类:
public class MyWebAppInitializer implements WebApplicationInitializer {
@Override
public void onStartup(ServletContext container) throws ServletException {
AnnotationConfigWebApplicationContext rootContext =
new AnnotationConfigWebApplicationContext();
rootContext.register(JpaSandboxConf.class);
ServletRegistration.Dynamic registration = container.addServlet("dispatcher", new DispatcherServlet());
registration.setLoadOnStartup(1);
registration.addMapping("/myapp/*");
}
}
Run Code Online (Sandbox Code Playgroud)
这似乎相当无可争议.为了得到
container.addServlet()
Run Code Online (Sandbox Code Playgroud)
方法,我把它包括在我的pom中:
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-servlet-api</artifactId>
<version>7.0.30</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我试过这个,但是下面的条目中的ServletContext类没有工作(因为它没有提供addServlet()方法):
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>com.springsource.javax.servlet</artifactId>
<version>2.5.0</version>
<scope>provided</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
当我尝试使用它时
mvn clean tomcat7:run
Run Code Online (Sandbox Code Playgroud)
我不幸得到了
SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[/]]
at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:252)
at java.util.concurrent.FutureTask.get(FutureTask.java:111)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1130)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:782)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1568)
at …
Run Code Online (Sandbox Code Playgroud) 我在测试和部署中遇到了一系列奇怪的错误.它们似乎表明我的一些bean没有加载到上下文中,尽管它们是在applicationContext.xml中定义的.
有没有办法在测试期间检查哪些bean实际已加载?或者查找运行时加载的bean的完整列表?
谢谢,b
我有一个叫做"边缘"的大数据
org.apache.spark.rdd.RDD[org.apache.spark.graphx.Edge[(String, Int)]] = MappedRDD[27] at map at <console>:52
Run Code Online (Sandbox Code Playgroud)
当我在独立模式下工作时,我能够收集,计算和保存此文件.现在,在群集上,我收到此错误
edges.count
...
Serialized task 28:0 was 12519797 bytes which exceeds spark.akka.frameSize
(10485760 bytes). Consider using broadcast variables for large values.
Run Code Online (Sandbox Code Playgroud)
与.saveAsTextFile("edges")相同
这是来自火花壳.我试过使用选项
--driver-java-options"-Dspark.akka.frameSize = 15"
但是,当我这样做时,它只会无限期地挂起.任何帮助,将不胜感激.
**编辑**
我的独立模式是在Spark 1.1.0上,我的集群是Spark 1.0.1.
此外,挂起发生在我计算,收集或保存作为RDD的时候,但定义它或对它做过滤器工作得很好.
假设我有类Student
,BadStudent:Student
,GoodStudent:Student
和ExcellentStudent: Student
.我想要一个只能Good
和Exceptional
学生一起操作的课程方法.就像是:
class AdvancedBasketWeaving {
// this is the question:
var acceptableStudentTypes: [1..2] = [GoodStudent, ExcellentStudent];
proc accept(student: Student) {
for at in this.acceptableStudentTypes {
if student.type == at then return "YES!";
}
return "Computer says 'No'";
}
}
Run Code Online (Sandbox Code Playgroud)
我如何获得此功能?
我有以下教堂代码。
proc update(x: int(32)) {
return 2*x;
}
proc dynamics(x: int(32)) {
return update(x);
}
writeln(dynamics(7));
Run Code Online (Sandbox Code Playgroud)
我想向 发送某种回调dynamics
,例如
proc update(x: int(32)) {
return 2*x;
}
proc dynamics(x: int(32), f: ?) {
return f(x);
}
writeln(dynamics(7, update));
Run Code Online (Sandbox Code Playgroud)
这可能吗?有我可以浏览的示例吗?
我似乎遇到了答案,然后我失去了它.我处在"迷失"阶段.如果我在Chapel中有一个对象,那么Python的等价物是什么
>>> thing = 'i am a thing'
>>> type(thing)
<type 'str'>
Run Code Online (Sandbox Code Playgroud)
我已经看到了,writeln(A.type)
并且writeln(type(A))
都抛出了表单的错误
'writeln(type _array(DefaultSparseArr(real(64),2,int(64),DefaultSparseDom(2,int(64),_domain(DefaultRectangularDom(2,int(64),false))))))'
$CHPL_HOME/modules/standard/IO.chpl:3992: note: candidates are: channel.writeln(out error: syserr) [233811]
$CHPL_HOME/modules/standard/IO.chpl:3998: note: channel.writeln() [233840]
$CHPL_HOME/modules/standard/IO.chpl:4006: note: channel.writeln(const args ...?k, out error: syserr) [233876]
$CHPL_HOME/modules/standard/IO.chpl:4012: note: channel.writeln(const args ...?k) [233916]
$CHPL_HOME/modules/standard/IO.chpl:4020: note: channel.writeln(const args ...?k, style: iostyle) [233954]
$CHPL_HOME/modules/standard/IO.chpl:4047: note: channel.writeln(const args ...?k, style: iostyle, out error: syserr) [233998]
$CHPL_HOME/modules/standard/IO.chpl:4267: note: writeln(const args ...?n) [235140]
$CHPL_HOME/modules/standard/IO.chpl:4273: note: writeln() [235158]
Run Code Online (Sandbox Code Playgroud) 继续这个问题,我现在有一个Graph
包含稀疏矩阵的类.定义如
class Graph {
var vdom: domain(2),
SD: sparse subdomain(vdom),
A: [SD] real;
proc init(A: []) {
this.vdom = {A.domain.dim(1), A.domain.dim(2)};
for ij in A.domain {
this.SD += ij;
}
}
Run Code Online (Sandbox Code Playgroud)
产生错误
chingon-base-test.chpl:30: error: halt reached - Sparse domain/array index out of bounds: (1, 2) (expected to be within {1..0, 1..0}
Run Code Online (Sandbox Code Playgroud)
似乎SD
没有重新定义.什么是正确的模式?在上一篇文章中,我们讨论了密集数组,这是稀疏的.
我通过它来称呼它
var nv: int = 8,
D: domain(2) = {1..nv, 1..nv},
SD: sparse subdomain(D),
A: [SD] real;
SD += (1,2); A[1,2] = …
Run Code Online (Sandbox Code Playgroud) 我想在数组上编写一个函数,但我想要一个泛型类型.对于论证,让我们把它作为一个总和.
proc mySum(x:[] int) {
return + reduce x;
}
proc mySum(x:[] real) {
return + reduce x;
}
Run Code Online (Sandbox Code Playgroud)
泛型类型的符号是什么?我认为它是类似的东西,proc mySum(x: [] <T>) {}
但不起作用.
如何从Scala中的Json对象中获取特定字段?我觉得我要进入圈子.
import org.json4s._
import org.json4s.jackson.JsonMethods._
val me = parse(""" {"name":"brian", "state":"frustrated"} """)
Run Code Online (Sandbox Code Playgroud)
现在我只想要国家.我在寻找类似的东西
me("state") -> "frustrated"
Run Code Online (Sandbox Code Playgroud)
我试过了
me("state")
me.get("state")
me \ "state" <thanks for the idea>
me['state']
me.state
me.NOOOOOOOOOO!!!!!!!
Run Code Online (Sandbox Code Playgroud)
救命?
在Python中,我可以很容易地从JSON创建对象.我可以填充类或只创建一个通用对象.我看到Chapel有一个read
JSON方法,但我不知道如何使用它.
如果我有:
class Fighter {
var subclass:string;
var level:int;
}
Run Code Online (Sandbox Code Playgroud)
和一个字符串:
s = "{'subclass':'Ninja', 'level':7}"
Run Code Online (Sandbox Code Playgroud)
我如何获得一个Fighter
对象?
是否有方法,如:
n = json.loads(s)
n['subclass'] # = 'ninja', but just as a field key
Run Code Online (Sandbox Code Playgroud)
要么:
Hattori = Fighter.read(s);
Hattori['subclass'] # = 'ninja'
Run Code Online (Sandbox Code Playgroud)
谢谢!
chapel ×6
scala ×2
spring ×2
spring-mvc ×2
apache-spark ×1
hpc ×1
json ×1
json4s ×1
rdd ×1
servlet-3.0 ×1