春天的定义ApplicationContext
非常模糊,我几乎完成了整本教程,但仍然无法理解它的ApplicationContext
立场.
根据Spring API,ApplicationContext
是:
用于为应用程序提供配置的中央接口.这在应用程序运行时是只读的,但如果实现支持,则可以重新加载.
用于访问Spring bean容器的根接口.这是bean容器的基本客户端视图.
从上面,我的问题是:
1)我一直看到书中提到的"容器",容器是指什么?一个容器是否意味着一个java进程?或一个容器是指一个ApplicationContext
对象?
2)如果我ApplicationContext
在一个java应用程序中实例化两个(都在main
体内),这两个接口是一个中央容器吗?还是两个单独的实例?看下面的代码,context1
和之间有什么区别context2
?如果有一个Singleton Beans.xml
,它是由context1
和context2
两个独立的实例或同一个实例调用的?
ApplicationContext context1 = new ClassPathXmlApplicationContext("Beans.xml");
ApplicationContext context2 = new ClassPathXmlApplicationContext("Beans.xml");
Run Code Online (Sandbox Code Playgroud) 如下面的代码:
public class Main {
public class innerPerson{
private String name;
public String getName(){
return name;
}
}
public static void main(String[] args){
ObjectMapper om = new ObjectMapper();
Map<innerPerson, String> map = new HashMap<innerPerson,String>();
innerPerson one = new Main().new innerPerson();
one.name = "david";
innerPerson two = new Main().new innerPerson();
two.name = "saa";
innerPerson three = new Main().new innerPerson();
three.name = "yyy";
map.put(one, "david");
map.put(two, "11");
map.put(three, "true");
try {
String ans = om.writeValueAsString(map);
System.out.println(ans);
} catch (JsonGenerationException e) {
// …
Run Code Online (Sandbox Code Playgroud) 有时我觉得使用AsyncTask对任务来说太过分了,我正在寻找类似于Android中的SwingUtilities.invokeLater的功能.因为我只想执行一行代码,没有必要为此创建一个新类.
实际上我想找到当我们将应用程序移动到SD卡时涉及哪些项目?我试图搜索,但所有答案都指向"如何将应用程序移动到SD",但实际上我只是想知道哪些项目已转移到SD以及剩下哪些项目.当我将应用程序移动到SD时,我可以看到仍有一些内存(在内部存储器中).我只是好奇剩下的东西是什么?应用程序实际移动到哪里(sd卡的哪一部分)?
阅读完文档后,我真的不明白这一点。有些使用像“CPU”这样的术语,但有些使用“核心”。
我在我的笔记本电脑上运行 Kubernetes 以进行测试。我的笔记本电脑有一个 CPU (2.2 GHz) 和四个内核。
如果我想为 pod 设置 CPU 请求/限制,我拥有的最大资源应该是 1000m 还是 4000m?
在 Kubernetes 上下文中,这里有什么区别(CPU 与核心)?
我已经google了一整天,并尝试了几乎所有建议的解决方案,没有一个是为我的日食工作,完全不知道出了什么问题,当我尝试通过Gradle构建时,它一直说"找不到tools.jar".
我做了什么:
1)在系统环境变量中添加Java Home(指向我的JDK).
2)在Path
系统环境变量中添加路径(包含tools.jar).
3)dependencies.gradle
在项目文件夹中创建文件,指示Gradle查找tools.jar(compile files("${System.properties['java.home']}/../lib/tools.jar")
)
4)直接把compile files("${System.properties['java.home']}/../lib/tools.jar")
在build.gradle dependencies
那里.
5)在项目首选项中,去Java -> Build Path -> Classpath
变量,添加JAVA_HOME
变量.
6)将项目构建路径指向JDK而不是JRE.
这些都不起作用!我还能尝试什么?
PS:Eclipse版本Mars 4.5.2,Gradle版本1.12
build.gradle内容(此构建脚本由eclipse自动生成):
apply plugin: 'java'
apply plugin: 'eclipse'
sourceCompatibility = 1.5
version = '1.0'
jar {
manifest {
attributes 'Implementation-Title': 'Gradle Quickstart',
'Implementation-Version': version
}
}
repositories {
mavenCentral()
}
dependencies {
compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
testCompile group: 'junit', name: 'junit', version: '4.+'
} …
Run Code Online (Sandbox Code Playgroud) 我很好奇地问这个,也许这是毫无意义的.
当我们在java中使用instanceof时,如:
if (a instanceof Parent){ //"Parent" here is a parent class of "a"
}
Run Code Online (Sandbox Code Playgroud)
为什么我们不能使用如下:
if (a instanceof Parent.class){
}
Run Code Online (Sandbox Code Playgroud)
从严格编程的角度来看,第二个'instanceof'是否更有意义?"Parent"和"Parent.class"有什么区别?
我从这里找到了解决方案: 使用iPhone SDK确定设备(iPhone,iPod Touch)
从链接中,它建议使用库https://gist.github.com/1323251
但显然这个图书馆已经过时了.我在列表中找不到iPhone 5和新iPad等.
有谁知道如何找到已完成和更新的列表?
非常感谢.
假设我的代码如下:
<!DOCTYPE HTML>
<html>
<head>
<style>
#overlay_form{
position: absolute;
border: 5px solid gray;
padding: 10px;
background: white;
width: 270px;
height: 190px;
}
#pop{
display: block;
border: 1px solid gray;
width: 65px;
text-align: center;
padding: 6px;
border-radius: 5px;
text-decoration: none;
margin: 0 auto;
}
</style>
<script src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
//open popup
$("#pop").click(function(){
$("#overlay_form").fadeIn(1000);
positionPopup();
});
//close popup
$("#close").click(function(){
$("#overlay_form").fadeOut(500);
});
});
//position the popup at the center of the page
function positionPopup(){
if(!$("#overlay_form").is(':visible')){
return;
}
$("#overlay_form").css({
left: ($(window).width() - $('#overlay_form').width()) …
Run Code Online (Sandbox Code Playgroud) 我已阅读Google Android Developer页面,但任务的概念(http://developer.android.com/guide/components/tasks-and-back-stack.html)确实让我感到困惑.
在我读到SingleTask和SingleInstance之后,我变得更加困惑.
我想通过一些例子提出一些问题,希望我能从这些问题中得到更好的理解:
假设我有2个应用程序A和B,A有x,y,z活动; B有1,2,3个活动:
假设他们的启动模式是标准(不使用任何意图标志).而x是app A的主要活动; 1是应用程序B的主要活动.
1)启动应用程序A,然后x-> y - > 1,按主页按钮,再次启动应用程序A,我们将看到活动y或1?
2)启动app A然后x - > 1 - > y - > 2 - > z - > 3,按home键,启动app A,它将包含所有活动(x - > 1 - > y - > 2 - > z - > 3),还是只包含x - > y - > z?如果我们现在推出应用B怎么样?应用B包含哪些活动?
现在让我们说活动1,2,3是SingleTask; x,y,z仍为标准:
3)启动应用程序A,然后x - > y - > 1 - > 2,按主页按钮,启动应用程序A,它将包含x - > y或它包含x - > y - > 1 - > …
java ×5
android ×3
build ×1
class ×1
css ×1
eclipse ×1
gradle ×1
html ×1
instanceof ×1
ios ×1
ipad ×1
iphone ×1
jackson ×1
jquery ×1
json ×1
kubernetes ×1
launchmode ×1
objective-c ×1
spring ×1
swing ×1