究竟是什么之间的技术差异console.writeline和System.out.println?我知道System.out.println写入标准输出但这与控制台不一样吗?
我不完全理解的文档进行console.writeline.
有兴趣了解人们通常如何检查Tomcat是否在Unix环境中运行.
我要么检查进程是否正在运行
ps -ef | grep java
ps -ef | grep logging
Run Code Online (Sandbox Code Playgroud)
或者我检查端口号是否有效
netstat -a | grep 8080
Run Code Online (Sandbox Code Playgroud)
有没有更好的方法来检查Tomcat是否正在运行?以上似乎是检查Tomcat运行的"hacky"方式.
在spring MVC应用程序中,我使用以下方法初始化其中一个服务类中的变量:
ApplicationContext context =
new ClassPathXmlApplicationContext("META-INF/userLibrary.xml");
service = context.getBean(UserLibrary.class);
Run Code Online (Sandbox Code Playgroud)
UserLibrary是我在我的应用程序中使用的第三方实用程序.上面的代码为'context'变量生成警告.警告如下所示:
Resource leak: 'context' is never closed
Run Code Online (Sandbox Code Playgroud)
我不明白这个警告.由于应用程序是一个Spring MVC应用程序,因此当我在应用程序运行时引用该服务时,我无法真正关闭/销毁上下文.试图告诉我的警告究竟是什么?
在以下程序中
class ZiggyTest2 {
public static void main(String[] args){
double x = 123.456;
char c = 65;
int i = 65;
System.out.printf("%s",x);
System.out.printf("%b",x);
System.out.printf("%c",c);
System.out.printf("%5.0f",x);
System.out.printf("%d",i);
}
}
Run Code Online (Sandbox Code Playgroud)
输出是
123.456trueA 12365
Run Code Online (Sandbox Code Playgroud)
有人可以解释一个双值(即123.456)如何转换为布尔值(即.true)
我问的原因是因为我知道java不允许数字用于布尔值.例如,Java中不允许以下内容
if (5) {
//do something
}
Run Code Online (Sandbox Code Playgroud)
谢谢
我按照以下步骤操作
我发现当我重新启动Tomcat时,先前展开的文件夹中的现有文件未更新.war文件的更新是否已更新相关的jsp,类文件?
我查看了文档,发现了这个http://tomcat.apache.org/tomcat-5.5-doc/config/host.html."自动应用程序部署"下的以下引用
除了发生在启动时自动部署,您还可以请求新的XML配置文件,WAR文件或子目录都在下降到的appBase(或
CATALINA_HOME/conf目录/ [引擎名称]/[host_name]等在$根据上述规则,将自动部署Tomcat运行时的XML配置文件目录.自动部署程序还将跟踪Web应用程序以进行以下更改:
- 对WEB-INF/web.xml文件的更新将触发Web应用程序的重新加载
- 对已扩展的WAR的更新将触发取消部署(删除扩展的webapp),然后部署
- 对XML配置文件的更新将触发取消部署(不删除任何扩展目录),然后部署关联的Web应用程序
由于上面的第2点,文件是否已自动更新?
autodeploy在server.xml中设置为true
为什么此示例中的输出为1?
public static void main(String[] args){
int[] a = { 1, 2, 3, 4 };
int[] b = { 2, 3, 1, 0 };
System.out.println( a [ (a = b)[3] ] );
}
Run Code Online (Sandbox Code Playgroud)
我以为会是2.即,表达式评估为:
a[(a=b)[3]]
a[b[3]] //because a is now pointing to b
a[0]
Run Code Online (Sandbox Code Playgroud)
不应该[0]为2,因为a指向b?
提前致谢.
我一直在寻找在多个warl文件之间共享会话数据的解决方案.我遇到了以下解决方案http://www.fwd.at/tomcat/sharing-session-data-howto.html
它的基本思想是,如果您有多个war文件,则可以使用所使用的第一个上下文的sessionid设置cookie.
可以使用将应用于所有上下文/应用程序的路径来设置cookie.
例如,如果我有3个应用程序的以下配置
/myapp/app1
/myapp/app2
/myapp/app3
Run Code Online (Sandbox Code Playgroud)
我可以按如下方式设置cookie
/ myapp sessionid.
然后,sessionid cookie将被发送到地址中带有/ myapp的任何请求.这允许会话id随后被任何上下文使用.
这种方法的唯一问题是它是在2003年编写的,并在Tomcat 4上进行了测试.
您对此方法有何看法?有没有更好的方法呢?
谢谢
我有3个maven项目
当我构建每个项目时,我必须进入每个文件夹并在每个项目上运行mvn clean install.
我已经研究过多模块项目,我看到的大部分资源都表明我必须对现有项目的结构进行更改.
是否有可能建立一个新项目来构建每个独立项目,而不必对现有项目中的任何内容进行任何更改,包括其各自的pom文件?
我可以通过编写一个构建每个项目的简单批处理文件来实现这一点但是可以使用Maven吗?
我已经配置了两个持久性单元,实体管理器设置如下:
<bean id="liveEntityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
p:dataSource-ref="LiveDataSource">
<property name="persistenceUnitName" value="LivePersistenceUnit" />
</bean>
<bean id="archiveEntityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
p:dataSource-ref="ArchiveDataSource">
<property name="persistenceUnitName" value="ArchivePersistenceUnit" />
</bean>
Run Code Online (Sandbox Code Playgroud)
然后我将事务管理器配置为
<bean id="LiveTransactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager"
p:entityManagerFactory-ref="liveEntityManagerFactory"/>
<bean id="ArchiveTransactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager"
p:entityManagerFactory-ref="archiveEntityManagerFactory"/>
Run Code Online (Sandbox Code Playgroud)
我最初只配置了一个,它被称为"transactionManager".Addint一个额外的持久单元似乎会产生错误.有一点我不明白,如果我配置了两个持久性单元(每个用于一个单独的数据库),我是否还需要为每个数据源配置一个单独的实体管理器和一个事务管理器?
我得到的错误如下所示:(我搜索了所有文件,我找不到任何有"transactionManager"参考的地方)
org.springframework.ws.soap.client.SoapFaultClientException: No bean named 'transactionManager' is defined
at org.springframework.ws.soap.client.core.SoapFaultMessageResolver.resolveFault(SoapFaultMessageResolver.java:37)
at org.springframework.ws.client.core.WebServiceTemplate.handleFault(WebServiceTemplate.java:774)
at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:600)
at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:537)
at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:384)
at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:378)
at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:370)
at com.ws.client.SoapTest.testFail(SoapTest.java:140)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) …Run Code Online (Sandbox Code Playgroud) 有人可以解释这个选项的目的以及它究竟是什么.
看起来我的eclipse安装默认是3.0但是它不能在Tomcat 5.5服务器上运行,可能不是Tomcat 6.0它是否与Tomcat服务器支持的servlet规范有关?如果是这样我需要为Tomcat 5.5和Tomcat 6.0使用哪个版本?
而且,我认为我使用的编译器版本与所选的Web模块版本之间存在链接.是否有某种文件可以解释这种关系是什么?
而且,为什么如果我选择v2.4 web模块,它默认为JDK 1.4?
谢谢