小编cum*_*lat的帖子

java.lang.NoClassDefFoundError:org / slf4j / LoggerFactory春季启动1.5.2 Maven

我正在按照本教程https://spring.io/guides/gs/rest-service/构建一个宁静的应用程序。当我从spring工具套件运行此应用程序(作为spring boot应用程序运行)时,它会抛出错误:

Caused by: java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
        at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:155)
        at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:132)
        at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:273)
        at org.springframework.boot.SpringApplication.<clinit>(SpringApplication.java:190)
        at webapp.Application.main(Application.java:9)
        ... 6 more
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
Run Code Online (Sandbox Code Playgroud)

当我尝试使用项目initializr(https://start.spring.io/)时,也会发生相同的错误。

我的pom.xml与教程完全一样:

<?xml version="1.0" encoding="UTF-8"?>
Run Code Online (Sandbox Code Playgroud)

http://maven.apache.org/xsd/maven-4.0.0.xsd“> 4.0.0

<groupId>com.rondox.sb.restfulws</groupId>
<artifactId>wawa</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>wawa</name>
<description>Demo project for Spring Boot</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.2.RELEASE</version>
    <relativePath /> <!-- lookup parent from repository -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.jayway.jsonpath</groupId>
        <artifactId>json-path</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>


<build>
    <plugins> …
Run Code Online (Sandbox Code Playgroud)

spring noclassdeffounderror slf4j maven spring-boot

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

React + Spring Boot上传文件和表单数据

我有一个像我的表单(前端)一样的情况,我可以填写个人数据(姓名、地址、出生日期),然后我可以附加多个图像。

在我的春季启动控制器中:

@RequestMapping(value = "/addCustOrder", method = RequestMethod.POST, consumes = {"multipart/form-data"})
    public String CustomerOrder(@ModelAttribute CustOrderRequest coReq, HttpServletRequest request) {
    System.out.println("debug ************** ");
    System.out.println("ReceiverName :: " + coReq.getReceiverName());
    System.out.println("attachmentFile :: " + coReq.getFileAttachment().length);
}
Run Code Online (Sandbox Code Playgroud)

我的模型包装:

public class CustOrderRequest {
    private String receiverName;
    private String receiverPhone;
    private String itemDescription;
    private MultipartFile[] fileAttachment;
}
//setter & getter 
Run Code Online (Sandbox Code Playgroud)

前端(React)代码:

const payload = JSON.stringify({
    id: values.id,
    receiverName: values.receiverName,
    receiverPhone: values.receiverPhone,
    itemDescription: values.itemDescription,
    fileAttachment: values.fileAttachment
});

axios.post(urlApi, payload)
    .then(r => {
    // success request 
    });
Run Code Online (Sandbox Code Playgroud)

通过上面的例子,我总是遇到错误。例如:java.io.IOException:流已关闭且附件长度为零/附件大小为零(从 …

java rest reactjs spring-boot axios

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

Apache mod_wsgi django 启用多线程多进程

题 :

  1. 我怎么知道我的 apache 服务器是否已经在多进程和多线程模式下运行?因为当我对其进行负载测试时,它给了我相同的结果时间和不同的线程数。我用 25 个线程和 50 个线程运行测试。

  2. 对于多线程/多进程工作,我必须在 Django 代码中做任何调整吗?

  3. 我必须更改 MPM 配置 (/conf/extra/httpd-mpm.conf) 吗?

以下是我的服务器详细信息和配置:

Server redhat enterprise 6.9
Apache server 2.4.33
Postgre 9.6.6
Python 3.6
Virtualbox RAM 8Gb, 2 Core (4 vCpu).
Run Code Online (Sandbox Code Playgroud)

我的 httpd.conf :

Listen 8000

LoadModule wsgi_module modules/mod_wsgi.so

Include conf/extra/httpd-vhosts.conf

WSGIScriptAlias / /home/applmgr/Harpa/HarpaBackend/harpa/wsgi.py
WSGIPythonHome /home/applmgr/Harpa/pyenv_sl
WSGIPythonPath /home/applmgr/Harpa/HarpaBackend
WSGIPassAuthorization On

<Directory /home/applmgr/Harpa/HarpaBackend/harpa>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
Run Code Online (Sandbox Code Playgroud)

我的 httpd-vhosts.conf :

<VirtualHost *:8000>

    Alias /static /home/applmgr/Harpa/HarpaBackend/static
    <Directory /home/applmgr/Harpa/HarpaBackend/static>
        Require all granted
    </Directory>

    WSGIDaemonProcess harpa …
Run Code Online (Sandbox Code Playgroud)

apache django multithreading mod-wsgi

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

包org.springframework.data.repository不存在spring boot jpa

我对spring boot + jpa有一个小问题。我已经将依赖项添加到POM.xml中,我可以从spring工具套件(作为spring boot应用程序运行)正常运行它。但是,当我从命令行“ mvn spring-boot:run”运行时,它将引发错误。

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building THA 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> spring-boot-maven-plugin:1.5.2.RELEASE:run (default-cli) > test-compile @ THA >>>
[WARNING] The POM for org.springframework:spring-jdbc:jar:4.3.7.RELEASE is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.jboss:jandex:jar:2.0.0.Final is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.springframework.data:spring-data-jpa:jar:1.11.1.RELEASE is invalid, transitive …
Run Code Online (Sandbox Code Playgroud)

java spring maven spring-data-jpa spring-boot

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