小编Koh*_*URA的帖子

在Windows上,Ctrl + C无法停止Maven启动Java进程的原因

我创建了一个可由Maven(mvn clean install exec:exec)运行的可执行Tomcat jar应用程序.Linux上的Ctrl+ 可以停止此应用程序C.但是,它无法在Windows上运行.有谁知道原因和解决方案?

环境:

$ mvn -version
Apache Maven 3.2.2 (45f7c06d68e745d05611f7fd14efb6594181933e; 2014-06-17T22:51:42+09:00)
Maven home: c:\apache-maven-3.2.2
Java version: 1.8.0_121, vendor: Oracle Corporation
Java home: c:\Program Files\Java\jdk1.8.0_121\jre
Default locale: ja_JP, platform encoding: MS932
OS name: "windows 7", version: "6.1", arch: "amd64", family: "dos"
Run Code Online (Sandbox Code Playgroud)

pom.xml的摘录:

<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.1</version>
    <executions>
        <execution>
            <id>tomcat-run</id>
            <goals>
                <goal>exec-war-only</goal>
            </goals>
            <phase>package</phase>
            <configuration>
                <path>/</path>
                <enableNaming>true</enableNaming>
                <finalName>embtest.jar</finalName>
                <charset>utf-8</charset>
            </configuration>
        </execution>
    </executions>
</plugin>
<plugin>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.6</version>
    <configuration>
        <failOnMissingWebXml>false</failOnMissingWebXml>
        <warName>ROOT</warName>
    </configuration>
</plugin> …
Run Code Online (Sandbox Code Playgroud)

java tomcat maven

5
推荐指数
1
解决办法
1732
查看次数

Spring Boot 中的 JSTL 支持

虽然我知道JSP 支持一些限制,但我想在 Spring Boot Web 应用程序中使用带有 JSTL 标签的 JSP。

我的 JSP 文件的摘录:

<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

...

<c:catch var="ex">
    <c:if test="${!fn:contains(param.template,'../') && !fn:startsWith(param.template,'/')}">
        <c:import url=    ...
Run Code Online (Sandbox Code Playgroud)

因此,我向 pom.xml 添加了以下依赖项:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>

<dependency>
    <groupId>org.apache.tomcat.embed</groupId>
    <artifactId>tomcat-embed-jasper</artifactId>
      <scope>provided</scope>
</dependency>

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>jstl</artifactId>
</dependency>
Run Code Online (Sandbox Code Playgroud)

但是,如果访问jsp,则抛出异常:

2017-08-14 13:09:32.259 ERROR 2376 --- [nio-8080-exec-2] o.a.c.c.C.[.[localhost].[/].[jsp]        : Servlet.service() for servlet [jsp] in context with path [] threw exception [The absolute uri: [http://java.sun.com/jsp/jstl/core] cannot be …
Run Code Online (Sandbox Code Playgroud)

spring jsp jstl maven spring-boot

5
推荐指数
1
解决办法
2万
查看次数

Django2应用程序安装"无法找到满足要求的版本"错误

我是新手Python/Django程序员.

我创建了一个基于Django 2.0的应用程序,并根据官方文档打包它.然后我运行命令:

$ pip install --user django-easybuggy-0.1.tar.gz
Run Code Online (Sandbox Code Playgroud)

但是,我收到错误,无法安装.

Processing ./django-easybuggy-0.1.tar.gz
Collecting certifi==2018.1.18 (from django-easybuggy==0.1)
  Could not find a version that satisfies the requirement certifi==2018.1.18 (from django-easybuggy==0.1) (from versions: )
No matching distribution found for certifi==2018.1.18 (from django-easybuggy==0.1)
Run Code Online (Sandbox Code Playgroud)

有谁知道错误发生的原因以及如何解决?

另外,我requirements.txt通过命令创建:

$ pip freeze > requirements.txt
Run Code Online (Sandbox Code Playgroud)

重现步骤:

  1. 下载我的应用档案:

    $ wget https://github.com/k-tamura/easybuggy4django/releases/download/0.0.1/django-easybuggy-0.1.tar.gz
    
    Run Code Online (Sandbox Code Playgroud)
  2. 运行命令:

    $ pip install --user django-easybuggy-0.1.tar.gz
    
    Run Code Online (Sandbox Code Playgroud)

最好的祝福,

python django pip setuptools python-3.x

5
推荐指数
1
解决办法
7526
查看次数

如何将java连接到ms access数据库

我正在尝试将 java 连接到 ms access 数据库,但效果不佳

我收到了这样的错误信息

sun.jdbc.odbc.JdbcOdbcDriver
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

import java.sql.*;

public class main{
    public static void main(String[] args) {

        try{
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            Connection con = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver(*.accdb)};DBQ=D:\\Andries\\testdatabase.accdb");
            Statement st = con.createStatement();
        }catch(Exception ex){
            System.out.println(ex.getMessage());
        }

    }
}
Run Code Online (Sandbox Code Playgroud)

java connection ms-access

4
推荐指数
1
解决办法
4万
查看次数

ESAPI.properties 中的最低要求属性

我的 Web 应用程序仅使用以下 ESAPI 编码方法:

  • ESAPI.encoder().encodeForLDAP()
  • ESAPI.encoder().encodeForHTML()

在这种情况下,ESAPI.properties 中最少需要的属性是什么?

现在我正在使用 ESAPI 2.1.0.1 和这个属性

java esapi

3
推荐指数
1
解决办法
4508
查看次数

流:通过供应商和累加器收集

我一直在尝试使用Stream 的收集方法,将列表转换为 HashMap。我使用下面的代码作为参考:

String result = list.parallelStream().collect(StringBuilder::new,
            (response, element) -> response.append(" ").append(element),
            (response1, response2) -> response1.append(",").append(response2.toString()))
            .toString();
Run Code Online (Sandbox Code Playgroud)

当我在 eclipse 中编写以下不完整的语句并在 ? 处执行ctrl+操作时space

Map<String,Choice> map1=  list1.stream().collect(()-> new HashMap<String,Choice>(), 
        (r,s) -> r.?,(r,s) -> r.putAll(s));
Run Code Online (Sandbox Code Playgroud)

考虑到使用 StringBuilder 的代码片段,我的期望是,累加器函数的第一个参数应该是 HashMap,因为我已使用 HashMap::new 作为供应商函数。根据这种理解,eclipse应该建议我使用HashMap的方法,但事实并非如此。

然而,这似乎工作正常

list1.stream().collect(ArrayList::new, ArrayList::add, ArrayList::addAll);
Run Code Online (Sandbox Code Playgroud)

已经提到了Java 8 Int Stream Collect with StringBuilder,但是,这方面运气不佳。

java java-8 java-stream

2
推荐指数
1
解决办法
1万
查看次数

春季靴子| LifecycleProcessor未初始化-在调用生命周期方法之前调用“刷新”

我有一个简单的spring boot应用程序,用于连接到REST api并查看其响应。这是一个用于原型制作的简单应用。但是我遇到以下错误:

java.net.BindException: Address already in use: bind
    at sun.nio.ch.Net.bind0(Native Method) ~[na:1.8.0_121]
    at sun.nio.ch.Net.bind(Unknown Source) ~[na:1.8.0_121]
    at sun.nio.ch.Net.bind(Unknown Source) ~[na:1.8.0_121]
    at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source) ~[na:1.8.0_121]
    at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source) ~[na:1.8.0_121]
    at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:228) ~[tomcat-embed-core-8.5.6.jar:8.5.6]
    at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:874) ~[tomcat-embed-core-8.5.6.jar:8.5.6]
    at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:590) ~[tomcat-embed-core-8.5.6.jar:8.5.6]
    at org.apache.catalina.connector.Connector.startInternal(Connector.java:969) [tomcat-embed-core-8.5.6.jar:8.5.6]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.5.6.jar:8.5.6]
    at org.apache.catalina.core.StandardService.addConnector(StandardService.java:225) [tomcat-embed-core-8.5.6.jar:8.5.6]
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.addPreviouslyRemovedConnectors(TomcatEmbeddedServletContainer.java:233) [spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.start(TomcatEmbeddedServletContainer.java:178) [spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.startEmbeddedServletContainer(EmbeddedWebApplicationContext.java:297) [spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:145) [spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:545) [spring-context-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) [spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
    at org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration.createChildManagementContext(EndpointWebMvcAutoConfiguration.java:193) [spring-boot-actuator-1.4.3.RELEASE.jar:1.4.3.RELEASE]
    at org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration.afterSingletonsInstantiated(EndpointWebMvcAutoConfiguration.java:156) [spring-boot-actuator-1.4.3.RELEASE.jar:1.4.3.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:779) [spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866) [spring-context-4.3.5.RELEASE.jar:4.3.5.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542) [spring-context-4.3.5.RELEASE.jar:4.3.5.RELEASE] …
Run Code Online (Sandbox Code Playgroud)

java rest client maven spring-boot

0
推荐指数
1
解决办法
5684
查看次数

如何重现 ClassCircularityError

有谁知道如何复制java.lang.ClassCircularityError以外的throw new ClassCircularityError(...)?如果可能,你能告诉我一个main()总是发生错误的示例程序吗?

根据Javadoc

当 Java 虚拟机检测到正在加载的类的超类层次结构中存在循环时抛出。

java jvm

0
推荐指数
1
解决办法
721
查看次数