我正在尝试在Eclipse J2EE透视图中使用Tomcat 7部署一个非常简单的HTTPServlet项目.我收到错误"Tomcat 7.0版仅支持J2EE 1.2,1.3,1.4和Java EE 5和6 Web模块".我已经尝试修改我在这里提到的org.eclipse.wst.common.project.facet.core.xml 文件,但似乎没有解决问题.我可以直接使用file-> export - > .war部署到我安装的tomcat服务器上.有任何想法吗?
我正在开发一个简单的应用程序并使用MediaPlayer在1个活动中播放一些背景噪音.我正在阅读MediaPlayer,我不确定是否要实现OnPreparedListener来触发start()方法.每种方法的优缺点是什么?
方法1:
mediaPlayer = MediaPlayer.create(context, R.raw.sound);
mediaPlayer.setLooping(true);
mediaPlayer.start();
Run Code Online (Sandbox Code Playgroud)
方法2:
mediaPlayer = MediaPlayer.create(context, R.raw.sound);
mediaPlayer.setLooping(true);
mediaPlayer.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mp.start();
}
});
Run Code Online (Sandbox Code Playgroud) 我正在开发一个项目,我们正在优化使用样板 jdbc 代码的遗留代码库,而在我们的新项目中,我们使用 springs jdbcTemplate。我发现遗留代码中的查询时间快了两倍,并且很好奇它的 jdbcTemplate 是否有问题或其他什么......
我们使用 apache commons BasicDataSource(提供池化)。我的问题是,我不太确定池化是否真的正常工作。下面是我的配置...
数据源
数据源的接线
为了分析这一点,我启动了应用程序并连接了所有 jdbc 的东西,然后简单地运行相同的查询 100 次。我还使用 log4j 来获取有关实际性能的一些指标。1 行将打印实际的 jdbc 调用时间,我在整个 jdbcTemplate 调用周围有一个额外的包装器,以查看整个过程需要多长时间(如下所示)...
编辑:添加 RowMapper 的图像
下面显示了我的日志的样子......
DEBUG org.springframework.jdbc.core.JdbcTemplate - Executing prepared SQL query
DEBUG org.springframework.jdbc.core.JdbcTemplate - Executing prepared SQL statement [my select query]
DEBUG org.springframework.jdbc.datasource.DataSourceUtils - Fetching JDBC
Connection from DataSource
DEBUG com.custom.frameworkx.spring.datasource.DebugDataSource - before executeQuery() sql=my select query
DEBUG com.custom.frameworkx.spring.datasource.DebugDataSource - after executeQuery() [time=30ms] sql=my select query
DEBUG com.custom.frameworkx.spring.datasource.DebugDataSource -
DebugResultSet.close()
DEBUG org.springframework.jdbc.datasource.DataSourceUtils - Returning JDBC …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Thymeleaf 作为我的模板引擎来设置一个非常简单的 Springboot 应用程序。我 %100 确定我的 @Controller 工作正常,但是当我尝试访问默认 url ("/") 时,我得到了可怕的“Whitelabel”错误页面。
下面是我的 gradle.build 文件...
buildscript {
ext { springBootVersion = '1.4.0.RELEASE' }
repositories { mavenCentral() }
dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") }
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'spring-boot'
jar {
baseName = 'masterSpringMvc'
version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories { mavenCentral() }
dependencies {
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-thymeleaf')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
eclipse {
classpath {
containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER')
containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8'
}
Run Code Online (Sandbox Code Playgroud)
很确定我的所有设置都正确,所以我继续运行以下构建步骤......
在此之后,我期待在我的“项目和外部依赖项”中看到spring-boot-starter-thymeleaf.jar但它不在那里。我对 Gradle 非常陌生,并假设构建会引入这个必需的依赖项,然后在启动我的应用程序时它会被“启用”。任何线索我可能在这里做错了什么? …
我的Maven清理安装失败了.以下是错误消息.
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile
(default-compile) on project MyProject: Compilation failure:
Compilation failure:
[ERROR] C:\..\MyClass.java:[13,2] cannot find symbol
[ERROR] symbol : class MyAnnotation
[ERROR] location: class mypackage.MyClass
Run Code Online (Sandbox Code Playgroud)
MyClass.java
public class MyClass{
@MyAnnotation
public static class MyAnnotation{
//some static nested class code here...
}
Run Code Online (Sandbox Code Playgroud)
MyAnnotation.java
@Retention (RetentionPolicy.RUNTIME)
public @interface MyAnnotation{
}
Run Code Online (Sandbox Code Playgroud)
我不知道为什么会出现问题,有人可以给我一些想法吗?
我有一个非常简单的SOAP客户端,我在wsimport实用程序的帮助下创建了我自己的Web服务.客户端工作原理非常好,但是当我添加一个处理程序时,它会中断.下面是我的工作客户端,它向控制台打印'1'...
public class MyFirstSoapClient {
public static void main(String args[]) {
SuperSimpleServiceService sib = new SuperSimpleServiceService();
ServiceEndpointInterface sei = sib.getSuperSimpleServicePort();
System.out.println(sei.return1());
}
}
Run Code Online (Sandbox Code Playgroud)
现在对于有趣的部分,这里是与处理程序实现相同的客户端,后跟输出...
public class MyFirstSoapClient {
public static void main(String args[]) {
SuperSimpleServiceService sib = new SuperSimpleServiceService();
sib.setHandlerResolver(new HandlerRegistration());
ServiceEndpointInterface sei = sib.getSuperSimpleServicePort();
System.out.println(sei.return1());
}
}
Run Code Online (Sandbox Code Playgroud)
产量
MyHandler: getHeaders
MyHandler: handleMessage
MyHandler: close
Exception in thread "main" com.sun.xml.internal.ws.streaming.XMLStreamReaderException: unexpected XML tag. expected: {http://interfaces.wsd.oce/}return1Response but found: {http://interfaces.wsd.oce/}return1
at com.sun.xml.internal.ws.streaming.XMLStreamReaderUtil.verifyTag(Unknown Source)
at com.sun.xml.internal.ws.streaming.XMLStreamReaderUtil.verifyTag(Unknown Source)
at com.sun.xml.internal.ws.client.sei.ResponseBuilder$DocLit.readResponse(Unknown Source)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source) …Run Code Online (Sandbox Code Playgroud) 在深入阅读Design Patterns(四人帮)一书之前,我想问一个普遍的问题......
本书的介绍提到它将使用C++作为主要代码示例,让任何Java专家阅读本书,我是否能够轻松地进行关联,甚至更重要的是,在Java中实现设计模式?
我知道这是一个有点模糊的问题,但如果这本书真正面向C++程序员,我不想浪费任何时间.
我期待着您的意见!
我目前正在使用Spring的JMS消息传递(JMSTemplate)的应用程序上工作。应用程序需要将消息发送到大型机队列,该大型机队列无法破译JMSTemplate附加到消息的“ RFH”头。有没有一种方法可以通过编程方式完全删除所有标头信息,以便大型机只获取没有标头的消息的原始内容?
这是我的代码...
MQQueueConnectionFactory connectionFactory = new MQQueueConnectionFactory();
connectionFactory.setHostName( "127.0.0.1" );
connectionFactory.setPort( 1414 );
connectionFactory.setChannel( "S_LOCALHOST" );
connectionFactory.setQueueManager( "QM_LOCALHOST" );
connectionFactory.setTransportType( 1 );
UserCredentialsConnectionFactoryAdapter credentials = new UserCredentialsConnectionFactoryAdapter();
credentials.setUsername( "" );
credentials.setPassword( "" );
credentials.setTargetConnectionFactory( connectionFactory );
JmsTemplate jmsTemplate = new JmsTemplate( credentials );
jmsTemplate.setPubSubDomain( false );
jmsTemplate.setDeliveryMode( javax.jms.DeliveryMode.NON_PERSISTENT );
jmsTemplate.setExplicitQosEnabled( true );
jmsTemplate.setReceiveTimeout( 60000 );
jmsTemplate.convertAndSend( "MY.QUEUE", "cobol data" );
Run Code Online (Sandbox Code Playgroud)
这是该消息在Websphere MQ Explorer中的外观。如何删除这些值?Spring JMS甚至可能吗?Lemme知道您是否需要更多信息...
我正在使用Netbeans 8.0.2.我使用File - > New Project - > Java Web:Web Application创建了一个非常简单的(什么是JSF)Web应用程序.
我试图在我的index.xhtml页面中打印一个@Named bean的实例变量,但它没有按预期工作.我正在使用Netbeans中的绿色"运行项目"按钮部署应用程序,该按钮自动打包,部署和启动浏览器.
在web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<context-param>
<param-name>MyContext</param-name>
<param-value>null</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
Run Code Online (Sandbox Code Playgroud)
的index.xhtml
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html">
<h:head>
<title>Facelets Hello Greeting</title>
</h:head>
<h:body>
<!-- I am expecting the beans name …Run Code Online (Sandbox Code Playgroud)