Tag Archives: java

Ali easyexcel error: org.apache.poi.ss.usermodel.font.setbold (z) V

public class TestEasyExcel {
	public static void main(String[] args) throws Exception {
		String filepath = "D:/LDT/测试easyExcel.xlsx";
		Sheet sheet = new Sheet(1, 0);
		sheet.setSheetName("xxxx");
		List<List<String>> header = new ArrayList<List<String>>();
		header.add(Lists.newArrayList("Number"));
		header.add(Lists.newArrayList("Name"));
		header.add(Lists.newArrayList("Age"));
		sheet.setHead(header);
		
		List<List<Object>> data = new ArrayList<List<Object>>();
		data.add(Lists.newArrayList("1001","Zhangsan",13));
		data.add(Lists.newArrayList("1002","Lisi",23));
		data.add(Lists.newArrayList("1003","Wangwu",33));
		
		OutputStream out = new FileOutputStream(new File(filepath));
		ExcelWriter writer = EasyExcelFactory.getWriter(out, ExcelTypeEnum.XLSX, true);
		System.out.println(writer);
		writer.write1(data, sheet);
		writer.finish();
	}
}

Error message: org.apache.poi.ss.usermodel.font.setbold (z) V

Cause: there is a conflict between Maven version and poi jar package. The following is Maven version. If POI version is 3.8 or 3.9, this exception message will appear.

        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>easyexcel</artifactId>
            <version>1.1.2-beta4</version>
        </dependency>

Solution: this exception will not occur in version 3.17 and above.

        <dependency>
			<groupId>org.apache.poi</groupId>
			<artifactId>poi</artifactId>
			<version>4.1.1</version>
		</dependency>
		<dependency> 
		    <groupId>org.apache.poi</groupId>
		    <artifactId>poi-ooxml</artifactId>
		    <version>4.1.1</version>
		 </dependency>

Ruoyi-cloud Integrated mybatis-plus Error: Unknown column ‘search_value‘ in ‘field list‘

Project scenario:
ruoyi cloud converts mybatis into mybatis plus, executes the querywrapper method, and always reminds of the error. Cause: java.sql.sqlsyntax errorexception: unknown column ‘search_ Value ‘in’ field list ‘
but the corresponding entity class did not find this field. After some efforts, the answer was found in an article, and finally the problem was solved!


Problem Description:

problem screenshot: 


Cause analysis:

because the database does not have this field, ruoyi cloud integrates baseentity, which contains this error field</ font>


Solution:

add annotation @tablefield (exist = false) to the corresponding entity class

Errors encountered when integrating activiti6 with springboot

There is also a spring-boot-autoconfigure-2.0.. release.jar in the start of 2.0 by default. If you also refer to activiti’s activiti-spring-boot-starter-rest-api.jar package, you need to exclude securityautoconfiguration.class in both packages

Write it in the startup class

@SpringBootApplication(exclude={
  org.activiti.spring.boot.SecurityAutoConfiguration.class,
  SecurityAutoConfiguration.class
})

Junit4 unit test reports an error invalid project specified

Junit4 unit test reports an error invalid project specified.

During the unit test the day before yesterday, an invalid project specified error was reported. After checking, it was found that the problem was the project name. If there are illegal characters such as’ – ‘or space in the project name, an error invalid project specified will be reported when running

ed.

Gateway forwards weboskct with an error ClassCastException

    usage environment: the springcloud gateway forwards an error message to the websocket. Error message content:

    15:30:38.092 [http-nio-9999-exec-1] ERROR c.m.g.e.GlobalErrorWebExceptionHandler - [handle,38] - org.apache.catalina.connector.ResponseFacade cannot be cast to reactor.netty.http.server.HttpServerResponse
    java.lang.ClassCastException: org.apache.catalina.connector.ResponseFacade cannot be cast to reactor.netty.http.server.HttpServerResponse
    	at org.springframework.web.reactive.socket.server.upgrade.ReactorNettyRequestUpgradeStrategy.getNativeResponse(ReactorNettyRequestUpgradeStrategy.java:182)
    	Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 
    Error has been observed at the following site(s):
    	|_ checkpoint ⇢ org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter [DefaultWebFilterChain]
    	|_ checkpoint ⇢ org.springframework.boot.actuate.metrics.web.reactive.server.MetricsWebFilter [DefaultWebFilterChain]
    	|_ checkpoint ⇢ HTTP GET "/sys/websocket/1" [ExceptionHandlingWebHandler]
    Stack trace:
    		at org.springframework.web.reactive.socket.server.upgrade.ReactorNettyRequestUpgradeStrategy.getNativeResponse(ReactorNettyRequestUpgradeStrategy.java:182)
    		at org.springframework.web.reactive.socket.server.upgrade.ReactorNettyRequestUpgradeStrategy.upgrade(ReactorNettyRequestUpgradeStrategy.java:162)
    		at org.springframework.web.reactive.socket.server.support.HandshakeWebSocketService.lambda$handleRequest$1(HandshakeWebSocketService.java:235)
    		at reactor.core.publisher.FluxFlatMap.trySubscribeScalarMap(FluxFlatMap.java:151)
    		at reactor.core.publisher.MonoFlatMap.subscribeOrReturn(MonoFlatMap.java:53)
    		at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:57)
    		at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    		at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    		at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    		at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    		at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64)
    		at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    		at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    		at reactor.core.publisher.Mono.subscribe(Mono.java:4252)
    		at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.drain(MonoIgnoreThen.java:172)
    		at reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:56)
    		at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64)
    		at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    		at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    		at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    		at com.alibaba.csp.sentinel.adapter.reactor.MonoSentinelOperator.subscribe(MonoSentinelOperator.java:40)
    		at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    		at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64)
    		at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
    
      cause of error: dependency conflict
      the Tomcat servlet of springboot is used in the request and the Tomcat of gateway netty is used in the response, so the type conversion exception is caused. Solution: modify the gateway POM file:
      delete or exclude the following dependencies

      <dependency>
      	<groupId>javax.servlet</groupId>
      	<artifactId>javax.servlet-api</artifactId>
      </dependency>
       <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-web</artifactId>
       </dependency>
       <dependency>
      	<groupId>javax.servlet</groupId>
      	<artifactId>jstl</artifactId>
      </dependency>
      <dependency>
      	<groupId>org.apache.tomcat.embed</groupId>
      	<artifactId>tomcat-embed-jasper</artifactId>
      </dependency>
      

How to Solve Springboot Upload Files Error: The field XXX exceeds its maximum permitted size of 1048576 bytes

When uploading a file using springboot, the following error is reported

 ERROR 11136 --- [nio-8080-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.web.multipart.MaxUploadSizeExceededException: Maximum upload size exceeded; nested exception is java.lang.IllegalStateException: org.apache.tomcat.util.http.fileupload.impl.FileSizeLimitExceededException: The field photos exceeds its maximum permitted size of 1048576 bytes.] with root cause

org.apache.tomcat.util.http.fileupload.impl.FileSizeLimitExceededException: The field photos exceeds its maximum permitted size of 1048576 bytes.
	at org.apache.tomcat.util.http.fileupload.impl.FileItemStreamImpl$1.raiseError(FileItemStreamImpl.java:114) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
	at org.apache.tomcat.util.http.fileupload.util.LimitedInputStream.checkLimit(LimitedInputStream.java:76) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
	at org.apache.tomcat.util.http.fileupload.util.LimitedInputStream.read(LimitedInputStream.java:135) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
	at java.io.FilterInputStream.read(FilterInputStream.java:107) ~[na:1.8.0_221]
	at org.apache.tomcat.util.http.fileupload.util.Streams.copy(Streams.java:98) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
	at org.apache.tomcat.util.http.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:291) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
	at org.apache.catalina.connector.Request.parseParts(Request.java:2922) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
	at org.apache.catalina.connector.Request.getParts(Request.java:2824) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
	at org.apache.catalina.connector.RequestFacade.getParts(RequestFacade.java:1098) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
	at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.parseRequest(StandardMultipartHttpServletRequest.java:95) ~[spring-web-5.3.9.jar:5.3.9]
	at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.<init>(StandardMultipartHttpServletRequest.java:88) ~[spring-web-5.3.9.jar:5.3.9]
	at org.springframework.web.multipart.support.StandardServletMultipartResolver.resolveMultipart(StandardServletMultipartResolver.java:122) ~[spring-web-5.3.9.jar:5.3.9]
	at org.springframework.web.servlet.DispatcherServlet.checkMultipart(DispatcherServlet.java:1202) ~[spring-webmvc-5.3.9.jar:5.3.9]
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1036) ~[spring-webmvc-5.3.9.jar:5.3.9]
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963) ~[spring-webmvc-5.3.9.jar:5.3.9]
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.3.9.jar:5.3.9]
	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) ~[spring-webmvc-5.3.9.jar:5.3.9]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:681) ~[tomcat-embed-core-9.0.52.jar:4.0.FR]
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.3.9.jar:5.3.9]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:764) ~[tomcat-embed-core-9.0.52.jar:4.0.FR]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.52.jar:9.0.52]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
	at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.3.9.jar:5.3.9]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.9.jar:5.3.9]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
	at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.3.9.jar:5.3.9]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.9.jar:5.3.9]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.3.9.jar:5.3.9]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.9.jar:5.3.9]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197) ~[tomcat-embed-core-9.0.52.jar:9.0.52]
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) [tomcat-embed-core-9.0.52.jar:9.0.52]
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542) [tomcat-embed-core-9.0.52.jar:9.0.52]
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135) [tomcat-embed-core-9.0.52.jar:9.0.52]
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) [tomcat-embed-core-9.0.52.jar:9.0.52]
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) [tomcat-embed-core-9.0.52.jar:9.0.52]
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357) [tomcat-embed-core-9.0.52.jar:9.0.52]
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:382) [tomcat-embed-core-9.0.52.jar:9.0.52]
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) [tomcat-embed-core-9.0.52.jar:9.0.52]
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:893) [tomcat-embed-core-9.0.52.jar:9.0.52]
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1726) [tomcat-embed-core-9.0.52.jar:9.0.52]
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.52.jar:9.0.52]
	at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) [tomcat-embed-core-9.0.52.jar:9.0.52]
	at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) [tomcat-embed-core-9.0.52.jar:9.0.52]
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.52.jar:9.0.52]
	at java.lang.Thread.run(Thread.java:748) [na:1.8.0_221]

Error reporting reason:

The upload size of a single file cannot be more than 1MB

The upload size of multiple files cannot be more than 10MB

Simple analysis of the underlying source code of springboot

// I have intercepted parts of both of these classes, so those who are interested can see for themselves

// Configuration class for file upload
public class MultipartProperties {
    private boolean enabled = true;
    private String location;

    // Default individual file size is 1MB
    private DataSize maxFileSize = DataSize.ofMegabytes(1L);
    
    // Default multiple file size is 10MB
    private DataSize maxRequestSize = DataSize.ofMegabytes(10L);
    
    private DataSize fileSizeThreshold = DataSize.ofBytes(0L);
    private boolean resolveLazily = false;
}

// Set file size
public final class DataSize implements Comparable<DataSize>, Serializable {
	/**
	 * The pattern for parsing.
	 */
	private static final Pattern PATTERN = Pattern.compile("^([+\\-]?\\d+)([a-zA-Z]{0,2})$");

	/**
	 * Bytes per Kilobyte.
	 */
	private static final long BYTES_PER_KB = 1024;

	/**
	 * Bytes per Megabyte.
	 */
	private static final long BYTES_PER_MB = BYTES_PER_KB * 1024;

	/**
	 * Bytes per Gigabyte.
	 */
	private static final long BYTES_PER_GB = BYTES_PER_MB * 1024;

	/**
	 * Bytes per Terabyte.
	 */
	private static final long BYTES_PER_TB = BYTES_PER_GB * 1024;


	private final long bytes;


	/**
	 * Obtain a {@link DataSize} representing the specified number of megabytes.
	 * @param megabytes the number of megabytes, positive or negative
	 * @return a {@link DataSize}
	 */
	public static DataSize ofMegabytes(long megabytes) {
		return new DataSize(Math.multiplyExact(megabytes, BYTES_PER_MB));
	}
}

Solution: you can customize the configuration in the properties or yaml configuration file to modify the maximum upload limit of spring boot file. Here I configure it in yaml

spring:
  mvc: 
  servlet:
    multipart:
      max-file-size: 10MB  		# Set the maximum size of a single file to 10MB
      max-request-size: 100MB # Set multiple file size to 100MB

Error starting ApplicationContext. To display the conditions report re-run your application with ‘de

Error starting ApplicationContext. To display the conditions report re-run your application with ‘debug’ enabled. How to Solve
Error Message:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-10-02 13:18:49.964 ERROR 7280 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Field navigationMapper in com.test.littleapp.controller.NavigationController required a bean of type 'com.test.littleapp.mapper.NavigationMapper' that could not be found.

The injection point has the following annotations:
	- @org.springframework.beans.factory.annotation.Autowired(required=true)


Action:

Consider defining a bean of type 'com.test.littleapp.mapper.NavigationMapper' in your configuration.

Solution:

Under the main file of spring boot application, add

@MapperScan("Your mapper name")

package com.test.littleapp;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@MapperScan("com.test.littleapp.mapper")
public class LittleappApplication {
    public static void main(String[] args) {
        SpringApplication.run(LittleappApplication.class, args);
    }
}

[Solved] Docker Error: Error response from daemon: driver failed programming external connectivity on endpoint

Error Message:

docker: Error response from daemon: driver failed programming external connectivity on endpoint kibana (16b783b436c6fc895f51866efea8a25c5748f7b3a78db1ec2cb0364e28e7feef): (iptables failed: iptables –wait -t nat -A DOCKER -p tcp -d 0/0 –dport 5601 -j DNAT –to-destination 172.17.0.4:5601 ! -i docker0: iptables: No chain/target/match by that name.
(exit status 1)).

Solution:
Docker reboot
You can register the iptables chain
Restart the Docker container

systemctl restart docker

springcloud alibaba Integrating nacos reports errors: create config service error!properties=NacosConfigPropertie

Solution:

First, check whether the YML file is configured

spring:    
    cloud:
        nacos:
          discovery:
            server-addr: 127.0.0.1:8848
      application:
        name: gulimall-member

If the configuration is completed, check whether the POM file references the configuration center

        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
        </dependency>

If so, just comment it out.

Problem reason: when Nacos config is used for unified configuration management, the bootstrap.properties configuration file is used to initialize the context when starting the springboot project.

When using the unified configuration of springcloudconfig, the loading order of spring boot configuration files is bootstrap.properties – & gt; bootstrap.yml -> application.properties -> Application.yml, where bootstrap.properties is configured as the highest priority.

Therefore, an error is reported if the properties file is not found during configuration.

If you need to use the Nacos configuration center, on the premise of referencing the above dependencies, you need to add the bootstrap.properties file in the resource directory, configure the service name, Nacos address and port number, and restart the service.

spring.application.name=gulimall-coupon
spring.cloud.nacos.config.server-addr=127.0.0.1:8848

 

Run hadoop fs -put Command Error: java.io.IOException: Got error, status message , ack with firstBadLink

After the Hadoop cluster is set up, the following port error occurs on one node when the Hadoop FS – put command is executed

location:org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.createBlockOutputStream(DFSOutputStream.java:1495)
throwable:java.io.IOException: Got error, status message , ack with firstBadLink as ip:port
at org.apache.hadoop.hdfs.protocol.datatransfer.DataTransferProtoUtil.checkBlockOpStatus(DataTransferProtoUtil.java:142)
at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.createBlockOutputStream(DFSOutputStream.java:1482)
at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.nextBlockOutputStream(DFSOutputStream.java:1385)
at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.run(DFSOutputStream.java:554)

First, check whether the firewalls of the three nodes are closed

firewall-cmd --state

Turn off firewall command

systemctl stop firewalld.service

If this situation still occurs after the firewall is closed, it may be that the ports of ECs are not open to the public. Take Alibaba cloud server as an example (Tencent cloud opens all ports by default):

After setting, execute the command again to succeed.

[Solved] JAVA Error: Error occurred during initialization of boot layer java.lang.module.FindException

Create new project error:
Error occurred during initialization of boot layer
java.lang.module.FindException: Error reading module: /Users/chenyue/eclipse-workspace/FirstBlood/bin
Caused by: java.lang.module.InvalidModuleDescriptorException: operear_test.class found in top-level directory (unnamed package not allowed in module)

Solution:
Delete the module-info.java in the directory bar