Author Archives: Robins

Mongodb uses Mongo to report error: could’t connect to server 127.0.0.1:27017, connection attempt failed: socket

Mongodb uses Mongo to report an error:

connecting to: mongodb://127.0.0.1 :27017/?compressors=disabled&gssapiServiceName=mongodb
2019-07-18T15:02:35.529+0800 E QUERY [js] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: ����Ŀ�����������ܾ����޷����ӡ� :
connect@src/mongo/shell/mongo.js : 342:17
there is a connection error when you enter Mongo on the command line

Solution:

Enter in the command line mongod.exe --dbpath E:\MongoDB\data\db

Among them, e:
do not close the CMD window, open a new CMD window again, and enter the Mongo command:

to open mongodb

IntelliJ idea solves Tomcat error: error listener start

When using idea, Tomcat can’t start normally, error prompt: org.apache.catalina . core.StandardContext.startInternal Error listener start. No more detailed error information.
Google has a plan to record Tomcat log details: create a new one in the project resource directory logging.properties File, enter the following into the file:

  handlers = org.apache.juli.FileHandler,java.util.logging.ConsoleHandler 
 org.apache.juli.FileHandler.level = FINE 
 org.apache.juli.FileHandler.directory = ${catalina.base}/logs 
 org.apache.juli.FileHandler.prefix = error-debug.

java.util.logging.ConsoleHandler.level = FINE 
 java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter

Restart tomcat, you will find more detailed error information under server.
My error message here:
caused by: org.springframework.context . annotation.ConflictingBeanDefinitionException : Annotation-specified bean name ‘newsManagerController’ for bean class [ com.qf.official . controller.NewsManagerController ] conflicts with existing, non-compatible bean definition of same name and class [ com.qf.bookbar . news.controller.NewsManagerController ].
because the name of a class has been modified before, which is duplicate with the class name in the system, the problem is solved by modifying the class name.

Resourceaccessexception: I / O error on post request for and connection timed out

1. Cause of error:

When the resttemplate is used to call the third-party API, the local test is normal, but when it is deployed to the server, it will report: Dan, 19:06 org.springframework.web . client.ResourceAccessException : I/O error on POST request for "XXX": No route to host (Host unreachable); nested exception is java.net.NoRouteToHostException : no route to host (host unreachable) , at first, I thought that the timeout was not set, so I configured it through online methods

 SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
 requestFactory.setConnectTimeout(10*1000);
 requestFactory.setReadTimeout(10*1000);
 RestTemplate rest = new RestTemplate(requestFactory);	

Deployment or error

2. Solutions

Finally, the interface setting the timeout time is replaced with httpcomponentsclienthttprequestfactory to solve the problem successfully

 HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
 requestFactory.setConnectTimeout(10*1000);
 requestFactory.setReadTimeout(10*1000);
 RestTemplate rest = new RestTemplate(requestFactory);

Docker delete error response from daemon: Conflict: unable to delete xxxxx solution

An error is reported when the docker image is deleted. After docker images , the output is as follows:

REPOSITORY                             TAG                        IMAGE ID            CREATED             SIZE
nvidia/cuda                            9.0-base                   74f5aea45cf6        6 weeks ago         134MB
paddlepaddle/paddle                    1.1.0-gpu-cuda8.0-cudnn7   b3cd25f64a2a        8 weeks ago         2.76GB
hub.baidubce.com/paddlepaddle/paddle   1.1.0-gpu-cuda8.0-cudnn7   b3cd25f64a2a        8 weeks ago         2.76GB
paddlepaddle/paddle                    1.1.0-gpu-cuda9.0-cudnn7   0df4fe3ecea3        8 weeks ago         2.89GB
hub.baidubce.com/paddlepaddle/paddle   1.1.0-gpu-cuda9.0-cudnn7   0df4fe3ecea3

The first image is successfully deleted by docker RMI 74f5aea45cf6 directly. However, the latter two images appear in pairs, and the direct docker RMI deletion fails. The error message is as follows:

Error response from daemon:
conflict: unable to delete b3cd25f64a2a (must be forced) - image 
is referenced in multiple repositories

Solution:

First, specify a name when docker RMI , instead of image ID , and then execute docker RMI - f image ID J

docker rmi paddlepaddle/paddle:1.1.0-gpu-cuda8.0-cudnn7
docker rmi -f b3cd25f64a2a

About error creating bean with name ‘xxxxx’: invocation of init method

The information found on the Internet is that this kind of exception is usually caused by wrong package import, missing, conflict and wrong version.

Before reporting this error again, I added, deleted and modified it pom.xml File, right-click project – & gt; Maven – & gt; update project, project – & gt; clean, etc. these operations are used to modify and update the project as a whole. It’s not good to directly locate the specific reason. So I went through the exception record carefully, and I checked in a java file that reported an error. I found that the point that reported an error was the override annotation. This is the reason why override annotation is not supported. Combined with previous experience, it is judged that the compiler version is low.

Solutions: 1. Right click on the project – & gt; build path – & gt; configure build path (then change the default 1.5 to your own JRE version: specifically, delete 1.5, and then add library – & gt; JRE system library – & gt; workspace default library (generally higher than 1.5, now at least 1.7, 1.8)).

2. Right click Project – & gt; properties – & gt; Java compiler. Remove the check “use compliance from execution environment on the Java build path”. Then, choose your own java version.

C Language Compilation Error: variably modified ‘* *’ at file scope

Error: variably modified ‘* *’ at file scope

Cause of error

Read only type used in array declaration.

This error is caused by the use of code similar to the following

const int length = 256;
char buffer[length] = {0};

In C language, const is not a real constant, its meaning is only read-only. The object declared with const is a runtime object and cannot be used as the initial value of a quantity, the length of an array, the value of a case, or in the case of a type. for example

//Error message in the comment
const int length = 256;
char buzzer[length];        //error: variably modified ‘buffer’ at file scope
int i = length;             //error: initializer element is not constant

switch (x) {
case length:            //error: case label does not reduce to an integer constant
	/* code */
	 break;
default:
	 break;
}

The solution is to use the macro definition instead of the read-only type const

//how to solve this error
#define LENGTH 256
char buzzer[LENGTH];        //error: variably modified ‘buffer’ at file scope
int i = LENGTH;             //error: initializer element is not constant

switch (x) {
case length:            //error: case label does not reduce to an integer constant
	/* code */
	 break;
default:
	 break;

#The difference between define and const
the type modified by const takes up space in memory, while # define does not. # define only replaces the corresponding part of the source file to be compiled with string before compilation. For example, the previous code will be preprocessed to

char buzzer[256];       
int i = 256;            

switch (x) {
case 256:           
	/* code */
	 break;
default:
	 break;

docker load Error processing tar file(exit status 1): archive/tar: invalid tar header

in use

$ docker load [image].tar

When the command uploads the docker image, an error is reported:

Load an image from a tar archive or STDIN

Add parameter – I

$ docker load -i [image].tar

Still report error:

Error processing tar file(exit status 1): archive/tar: invalid tar header

Solution reference: https://stackoverflow.com/questions/40622162/docker-load-and-save-archive-tar-invalid-tar-header

reason:

Running docker save and docker load in different operating systems will cause this problem. Even on different physical machines, the same operating system may also appear.

Solution:

add the parameter – O when the docker is saved. Refer to the official website https://docs.docker.com/engine/reference/commandline/save/

Run on the machine where you want to save the. Tar image:

docker save -o [image].tar

Run on the machine that needs to be uploaded:

docker load -i [image].tar

Error assembling War: webxml attribute is required

Error information:

Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/ web.xml

The project started by springboot reported an error.

Solution:

<!-- Building a WAR without a web.xml file
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.0.0</version>
            </plugin>
            -->
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <!--Set to false if you want to build the WAR without the web.xml file.-->
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>