我正在尝试设计一个rest api,下面是我的控制器代码。
当我调用http://localhost:8080/ 时,响应很好,但是如果我点击http://localhost:8080/api/ca它会触发javax.servlet.ServletException: No adapter for handler [...CaDetailController@48224381]: The DispatcherServlet configuration needs to include a HandlerAdapter that supports this handler
@RestController("/api")
public class CaDetailController {
private static final Logger logger = LoggerFactory.getLogger(GetClassLoader.class.getClass());
@Autowired
CaService caService;
@RequestMapping(path = "/ca", method = RequestMethod.GET)
public @ResponseBody List<CaDetail> getCorporateActions() {
logger.info("CaDetailController.findAllCaDetails()");
return caService.findAllCaDetails();
}
@RequestMapping(path = "/ca/{caId}", method = RequestMethod.GET)
public @ResponseBody List<CaDetail> getCorporateActions(@PathParam("caId") long caId) {
logger.info("CaDetailController.getCorporateActions() : caId : " + caId);
return caService.findAllCaDetails();
}
} …Run Code Online (Sandbox Code Playgroud) 我正在使用bootstrap 3硅藻土选择器小部件,但我无法控制它的位置.现在,当我不使用水平和垂直选项时,小部件显示在我的页面底部,但是当我使用水平和垂直选项时,我得到一个错误,说水平不是有效选项.
这些选项对我不起作用:
水平:'右',
垂直:'顶'
这是我的代码:
enter code here
<input type="text" value="<fmt:formatDate value="${visitDetail.visitDate }" pattern="dd-MM-yyyy hh:mm aaa" />" name="patient.visitDetails[${status.index}].visitDate" class="form-control" id="visitDate${status.index}" placeholder="visitDate${status.index}">
<script type="text/javascript">
$(function () {
$("#visitDate${status.index}").datetimepicker({
showTodayButton: true,
inline: false,
format: "DD-MM-YYYY hh:mm A",
sideBySide: true,
horizontal: 'right',
vertical: 'top'
});
});
</script>
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用LocalDateTime.parse该方法解析日期,但是我遇到了以下错误。如果我使用SimpleDateFormat简单的日期格式对象,则日期字符串将被解析。
有没有人遇到这个问题!从DateFormat和解析之间有什么区别LocalDateTime
package com.example.demo;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
public class App {
public static final String DATE_TIME_PATTERN = "dd-MM-yyyy hh:mm:ss.SSS";
public static final DateFormat DATE_TIME_FORMAT = new SimpleDateFormat(DATE_TIME_PATTERN);
public static final String SEPERATOR = ",";
public static void main(String[] args) {
try {
Date date = DATE_TIME_FORMAT.parse("12-03-2019 10:28:50.013");
System.out.println("date : {} " + date);
LocalDateTime startTimestamp = LocalDateTime.parse("12-03-2019 10:28:50.013", DateTimeFormatter.ofPattern(DATE_TIME_PATTERN)).plusNanos(1000000);
System.out.println("startTimestamp : {} " + startTimestamp);
} …Run Code Online (Sandbox Code Playgroud) 我在 EJB 3.1 中有 EJB,我试图在 JBoss EAP 6 中部署它,但是当我启动服务器时。它在 JNDI 名称中附加版本号,如下所示。
18:27:57,068 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-6) JNDI bindings for session bean named TestService in deployment unit subdeployment "TestGroup-war-3_0_0-SNAPSHOT.war" of deployment "TestGroup-ear-3_0_0-SNAPSHOT.ear" are as follows:
java:global/TestGroup-ear-3_0_0-SNAPSHOT/TestGroup-war-3_0_0-SNAPSHOT/TestService!org.pkg.ejb.local.CRMDataServiceLocal
java:app/TestGroup-war-3_0_0-SNAPSHOT/TestService!org.pkg.ejb.local.CRMDataServiceLocal
java:module/TestService!org.pkg.ejb.local.CRMDataServiceLocal
java:global/TestGroup-ear-3_0_0-SNAPSHOT/TestGroup-war-3_0_0-SNAPSHOT/TestService
java:app/TestGroup-war-3_0_0-SNAPSHOT/TestService
java:module/TestService
Run Code Online (Sandbox Code Playgroud)
如何从 JNDI 名称中删除版本号“-3_0_0-SNAPSHOT”?我有 ejb-jar.xml,当我部署耳朵时,它被放置在 ejb jar 文件中。
为什么不将 bean 放入 applicationContext.xml 就不会调用 post 构造
这是我的类,其中包含 @PostConstruct 注释。
package org.stalwartz.config;
import javax.annotation.PostConstruct;
import javax.inject.Singleton;
@Singleton
public class PropertyLoader {
@PostConstruct
public void init() {
System.out.println("PropertyLoader.init()");
}
}
Run Code Online (Sandbox Code Playgroud)
下面是我的 applicationContext.xml
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.directwebremoting.org/schema/spring-dwr
http://www.directwebremoting.org/schema/spring-dwr/spring-dwr-3.0.xsd">
<dwr:annotation-config />
<dwr:annotation-scan base-package="org.stalwartz" scanDataTransferObject="true" scanRemoteProxy="true" />
<dwr:url-mapping />
<!-- <bean id="proeprtyLoader" class="org.stalwartz.config.PropertyLoader"></bean> -->
<dwr:controller id="dwrController" debug="false">
<dwr:config-param name="activeReverseAjaxEnabled" value="true" />
</dwr:controller>
<context:annotation-config>
<context:component-scan base-package="org.stalwartz" annotation-config="true"></context:component-scan>
</context:annotation-config>
<mvc:annotation-driven />
...
... …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 ntlm Auth Scheme 使用 http 客户端从服务器下载 pdf 文件。
但是当我遇到错误时。当我使用 wget 和用户名和密码作为参数时,文件正在下载,但如果我使用相同的用户名和密码,它会使用 java 代码失败并显示 401。我正在使用 httpclient 4.2.2
Authentication error: No valid credentials provided (Mechanism level: No valid credentials provided
(Mechanism level: Failed to find any Kerberos tgt))
Run Code Online (Sandbox Code Playgroud)
下面是我使用 auth 下载 pdf 的代码。
public ByteArrayOutputStream getFile1(String resourceURL) throws CRMBusinessException {
DefaultHttpClient httpclient = new DefaultHttpClient();
ByteArrayOutputStream tmpOut = null;
try {
ICRMConfigCache cache = CacheUtil.getCRMConfigCache();
String host = cache.getConfigValue(ConfigEnum.DOCUMENT_SOURCE_HOST_NAME.toString());
String user = cache.getConfigValue(ConfigEnum.HTTP_USER_NAME.toString());
String password = cache.getConfigValue(ConfigEnum.HTTP_PASSWORD.toString());
String workstation = cache.getConfigValue(ConfigEnum.CLIENT_HOST_NAME.toString()); …Run Code Online (Sandbox Code Playgroud) 我收到以下错误:
Caused by: javax.faces.el.EvaluationException: java.lang.IllegalArgumentException: Comparison method violates its general contract!
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:101) [jboss-jsf-api_2.1_spec-2.1.28.SP1-redhat-1.jar:2.1.28.SP1-redhat-1]
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:101) [jsf-impl-2.1.28.redhat-10.jar:2.1.28.redhat-10]
at javax.faces.component.UICommand.broadcast(UICommand.java:315) [jboss-jsf-api_2.1_spec-2.1.28.SP1-redhat-1.jar:2.1.28.SP1-redhat-1]
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:786) [jboss-jsf-api_2.1_spec-2.1.28.SP1-redhat-1.jar:2.1.28.SP1-redhat-1]
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1251) [jboss-jsf-api_2.1_spec-2.1.28.SP1-redhat-1.jar:2.1.28.SP1-redhat-1]
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81) [jsf-impl-2.1.28.redhat-10.jar:2.1.28.redhat-10]
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.28.redhat-10.jar:2.1.28.redhat-10]
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.1.28.redhat-10.jar:2.1.28.redhat-10]
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) [jboss-jsf-api_2.1_spec-2.1.28.SP1-redhat-1.jar:2.1.28.SP1-redhat-1]
... 29 more
Caused by: java.lang.IllegalArgumentException: Comparison method violates its general contract!
at java.util.TimSort.mergeHi(TimSort.java:899) [rt.jar:1.8.0_65]
at java.util.TimSort.mergeAt(TimSort.java:516) [rt.jar:1.8.0_65]
at java.util.TimSort.mergeForceCollapse(TimSort.java:457) [rt.jar:1.8.0_65]
at java.util.TimSort.sort(TimSort.java:254) [rt.jar:1.8.0_65]
at java.util.Arrays.sort(Arrays.java:1512) [rt.jar:1.8.0_65]
at java.util.ArrayList.sort(ArrayList.java:1454) [rt.jar:1.8.0_65]
at java.util.Collections.sort(Collections.java:175) [rt.jar:1.8.0_65]
Run Code Online (Sandbox Code Playgroud)
下面是我的比较方法代码.vo1.getAttribute()返回java.util.DateObject.
@Override
public int compare(DateComparableVO …Run Code Online (Sandbox Code Playgroud) 在我正在阅读Java的书中,它通过使用写入文件并将其存储的程序来演示序列化.我收到一个奇怪的错误,我不知道如何阅读,它拒绝我访问创建.txt文件.这是错误:
Exception in thread "main" java.io.FileNotFoundException: C:\testFile.txt (Access is denied)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at serializableTests.MyProgram.main(MyProgram.java:18)
Run Code Online (Sandbox Code Playgroud)
这是该计划的两个类:
用户类:
public class User implements Serializable {
private static final long serialVersionUID = 4415605180317327265L;
private String username;
private String password;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
Run Code Online (Sandbox Code Playgroud)
这是主要课程:
import java.io.File;
import java.io.FileOutputStream; …Run Code Online (Sandbox Code Playgroud) 是否可以在下面一行中使用Java8编写所有空字符串和空字符串检查的代码?
Map<Integer, Map<String, Object>> data = new HashMap<>(holdings.rowMap());
Set<Entry<Integer, Map<String, Object>>> entrySet = data.entrySet();
double transactedQuantity = 0;
for (Entry<Integer, Map<String, Object>> entry : entrySet) {
Map<String, Object> value = entry.getValue();
Object qty = value.get("quantity");
if (qty != null && qty != "") {
transactedQuantity += Double.valueOf(qty.toString());
}
}
Run Code Online (Sandbox Code Playgroud)
像下面这样
data.values().stream().filter((k,v) -> k.equals("quantity") && v != null && v != "").flatMapToDouble(...);
Run Code Online (Sandbox Code Playgroud) 我是 Kafka 新手,尝试安装并运行控制台消费者,但出现错误java.lang.IllegalStateException: There are no in-flight requests for node -1
我尝试的环境如下
Kafka Version kafka_2.13-2.6.0
MacOS java11 Fails
MacOS java 1.8 Fails
Windows 10 Java11 Success
Run Code Online (Sandbox Code Playgroud)
以下是我正在执行的详细步骤。相同的步骤适用于 Windows。
步骤 1 下载卡夫卡
我刚刚从https://www.apache.org/dyn/closer.cgi?path=/kafka/2.6.0/kafka_2.13-2.6.0.tgz下载了 Kafka
STEP 2 启动zookeeper服务,工作正常。
我用以下命令启动动物园管理员
bin % zookeeper-server-start.sh ../config/zookeeper.properties
Run Code Online (Sandbox Code Playgroud)
这是动物园管理员日志
[2020-08-30 14:28:52,234] INFO Server environment:java.io.tmpdir=/var/folders/q7/khp8p9k14rzfs_zl52m57hlr0000gn/T/ (org.apache.zookeeper.server.ZooKeeperServer)
[2020-08-30 14:28:52,234] INFO Server environment:java.compiler=<NA> (org.apache.zookeeper.server.ZooKeeperServer)
[2020-08-30 14:28:52,234] INFO Server environment:os.name=Mac OS X (org.apache.zookeeper.server.ZooKeeperServer)
[2020-08-30 14:28:52,234] INFO Server environment:os.arch=x86_64 (org.apache.zookeeper.server.ZooKeeperServer)
[2020-08-30 14:28:52,234] INFO Server environment:os.version=10.15.6 (org.apache.zookeeper.server.ZooKeeperServer)
[2020-08-30 14:28:52,234] INFO Server …Run Code Online (Sandbox Code Playgroud) java ×4
java-8 ×2
apache-kafka ×1
comparator ×1
date ×1
ejb-3.1 ×1
exception ×1
java-io ×1
java-stream ×1
jboss-eap-6 ×1
jboss6.x ×1
jndi ×1
macos ×1
spring ×1
spring-boot ×1
spring-mvc ×1
spring-rest ×1