Author Archives: Robins

Using global timing task cronutil in hutool tool class

The original address: https://www.cnblogs.com/xiaolong1996/p/9571645.html
Use the global timing task-cronutil in the Hutool utility class
Spring’s @Autowired annotation is used to inject the required service. When the add method in the service is called, the program raises a null pointer exception. In the thread, it is thread-safe, injection-resistant, and is resolved by the context object instance
 
package com.backstage.config;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
/
* * * @ ProjectName:
* @ Package: com. Runs backstage. Config
* @ the ClassName: ApplicationContextProvider
* @ Description: get bean object tools
* @ Author: wangzhilong @ CreateDate
* :
* @version: 1.0
/
Author: * *
* ZhuShangJin Date:
* 2018/7/3/

* @ Component
public class ApplicationContextProvider implements ApplicationContextAware {

/* * *
the context object instance */
private static ApplicationContext ApplicationContext;
@Override
public void setApplicationContext(ApplicationContext) throws BeansException {
is.ApplicationContext = ApplicationContext;
}
/**
* @return
@return
* @return
publ>tatic ApplicationContext getApplicationContext() {
}

/* * * by the name for the Bean.

* * * @ @ param name
the return/

* public static Object getBean (String name) {
the return getApplicationContext().getBean(name);
}
/
* * * by class get beans.

* * @ param clazz
* @ param & lt; T>
* @ return/

* public static & lt; T> T getBean(Class< T> Clazz) {
return getApplicationContext () getBean (clazz);
}
/ * *
* by name, and the return of the Clazz specified Bean

* * @ param name
* @ param Clazz
* @ param & lt; T>
* @ return/

* public static & lt; T> T getBean(String name, Class< T> Clazz) {
return getApplicationContext().getBean(name, clazz);
}
 
Public TimingMonitoring () {//new injection need bean enclosing detailedDataService = ApplicationContextProvider. GetBean (detailedDataService. Class); }
}
 

MySQL advanced — Explanation of ref field in explain information

1. Explain the ref field in the Explain information
Indicates which column of the index is used, if possible, as a constant. Which columns or constants are used to find values on indexed columns
2. Explain the ref field in the information

From key_len we can see that IDX_COL1_COL2 of table T1 is fully used, that col1 matches col1 of table T2, and that col2 matches a constant, that is, the fields associated with other tables in the ‘AC’ query, and that the foreign key relationship is indexed

The problem that headers [‘content-type ‘] does not work is set in the Axios get method request interface

The request headers are set in the Axios wrapper request method and are not present in the Request Headers

service.interceptors.request.use(
    config => {
        config.data = JSON.stringify(config.data);
        config.headers['Authorization'] = getToken();
        config.headers['Content-Type'] = "application/json;charset=utf-8";
        
        return config;
    },
    error => {
        return Promise.reject();
    }
);

The Axios source code under NPM removes the Content-Type setting when RequestData is not set

// Add headers to the request
if ('setRequestHeader' in request) {
    utils.forEach(requestHeaders, function setRequestHeader(val, key) {
    if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
      // Remove Content-Type if data is undefined
      delete requestHeaders[key];
    } else {
      // Otherwise add header to the request
      request.setRequestHeader(key, val);
    }
  });
}

Solution:
If (typeof requestData === ‘undefined’ & & Key.tolowerCase () === ‘Content-Type ‘)
2. Assign config.data = true to requestData

service.interceptors.request.use(
    config => {
        config.data = JSON.stringify(config.data);
        config.headers['Authorization'] = getToken();

        config.data = true
        config.headers[ 'Content-Type'] = "application/json;charset=utf-8";

        return config;
    },
    error => {
        return Promise.reject();
    }
);

 
Reference data: https://blog.csdn.net/qq_24729895/article/details/80367460

Solutions to the problem of “Autowired cannot be resolved to a type” in eclipse Maven project

Autowired cannot be resolved to a type;
Question screenshot:
First thought: There should be a missing JAR package. Find the corresponding package as follows:

Click the corresponding class to open the problem as follows:

It should be obvious that there is a problem with the JAR, find the local repository, delete the JAR, and download it again. Right-click the project in Eclipse and expand Run As, then select Maven Install and re-download the JAR package.
You can see the JAR package being downloaded in the console window:

Once the JAR package has been downloaded, the problem can be resolved without incident. This solution is personally measured, not necessarily able to solve your problem, do not like spray! Thanks for communicating!

Error resolution of ‘string’ does not name a type

‘string’ does not name a type Although it is not the first time to meet, but still delay for a while, in order not to delay time, so write down the mistake

Example understanding:

#ifndef EMP_H 
#define EMP_H 
#include <string> 
 
struct menuEntry  
{  
    string uID;    //error: 'string' does not name a type 
    string uName;  //error: 'string' does not name a type 
}; 
 
#endif//EMP_H
#ifndef EMP_H 
#define EMP_H 
#include <string> 
 
struct menuEntry  
{  
    std::string uID;      /* ok */       
    std::string uName;    /* ok */
 }; 
 
#endif//EMP_H

using namespace STD; using namespace STD;
don't forget to include the header file. string>

Error resolution of unexpected token in JSON at position 0

This error, or a similar error, can occur when you send an HTTP request, perhaps using a FETCH or other Ajax library.
then I will explain this is caused by what, how should we solve these problems
1.
These errors occur when you send a request to the server that returns a value that is not JSON but is parsed using JSON methods. The code that does this might look like this.
the fetch (‘/users’). Then (res = & gt; Res.json ())
The actual request is fine, it gets a return value, and the key to the problem is res.json(). Parse
json. parse( not a JSON string )>arse
json. parse( is not a JSON string );
json.parse () is essentially the same as res.json(), so the error cases are the same.
3. Invalid JSON
unexpected token o in JSON at position 1″
error prompt Some differences will vary depending on the server return
The symbol or location it prompts may be different, but the reason for it is the same: all the JSON your code parses is not really valid JSON.
> Here are some errors I’ve seen:
Unexpected token < in JSON at position 1
Unexpected token p in JSON at position 0
Unexpected token d in JSON at position 0
4.
With fetch, you can use res.text() instead of res.json() to get the text string itself. Alter your code to read something like this, And check the console to see what’s causing the problem:
first prints out the return value. If you’re using fetch, you can use res.text() instead of res.json() to get the string. Convert your code to something like this and look at the print to see what went wrong.
fetch(‘ /users’)
/. Then (res =>; res.json()) // comment this out for now
.then(res => res.text()) // convert to plain text
.then(text => Console. log(text)) // Then log it out
Note that methods like res.json() and res.text() are asynchronous. So you can’t print out their return values directly, which is why console.log must be inside the parentheses of.then.
5. Is it the server?
server returns HTML instead of JSON for several reasons:
The requested URL does not exist. The server returns the 404 page as HTML. You may have code errors in the request (like /user instead of /users), or errors in the server code.
When a new route is added, the server needs to be restarted. Get (‘ /users’,…) : app.get(‘ /users’…) Route, but without a restart, the server will not respond to the new route address.
client proxies are not set: If you are using a Webpack Dev server like the Create React App, you can set a proxies that point to the back-end server.
API root URL is /. If you are using proxies through Webpack or the Create React App, make sure your API route is not at the root level /. This will confuse the proxy server and you will get an HTML return instead of your API request. You can put a prefix like/API/in front of such as.
is a 404 page?(This may be a missing address or a mistyped code).
Is this the page for index.html?(It could be a missing address or an agent configuration error)
If everything looks good (new address, the server doesn’t restart), and then restart the front-end and back-end server, see if problem solved italic style * *
from: https://segmentfault.com/a/1190000017545154

JS error: unexpected token u in JSON at position 0

At first glance, this error is confusing, but it is simply due to json.parse parsing of undefined.

JSON.parse is used somewhere, but the argument passed in is not a qualified JSON string.
Parse parse parse parse parse parse parse parse parse parse
Parse before you judge
 


Come from:
https://www.cnblogs.com/yangxunwu1992/p/8964780.html

Fatal error in PHP project: class’ redis’ not found

 
Reason 1: The PHP extension php_redis is not installed.
Reason 2: For Windows, pay attention to the PHP version (5.4, 5.6, 7.0) and compilation type (x86, x64)
 
Php_redis download address: http://pecl.php.net/package/redis
 
You can view the PHP version and compilation type using the phpinfo function