Author Archives: Robins

[Solved] Springboot Start main program service error: required a single, but 2 were found

required a single , but 2 were found
Error:

***************************
APPLICATION FAILED TO START
***************************
Description:
Field messageService in com.sto.unify.app.jnv2.controller.biz.TaskCenter.TaskCenterController required a single bean, but 2 were found:
    - taskMessageServiceImpl: defined in file [/Users/zgz/IdeaProjects/sto-app-face/sto-app-face-jn/sto-app-face-jn-service/target/classes/com/sto/unify/app/jnv2/service/core/task/impl/TaskMessageServiceImpl.class]
    - taskMessageService: defined in file [/Users/zgz/IdeaProjects/sto-app-face/sto-app-face-jn/sto-app-face-jn-service/target/classes/com/sto/unify/app/jnv2/service/core/task/TaskMessageService.class]
Action:
Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed

Error reason:

It may be that maperscan scans all the packages during scanning. Change it to the following

[Solved] Oracle Error: SGA_MAX_SIZE cannot be set to more than MEMORY_TARGET

Oracle reports error: SGA_MAX_SIZE cannot be set to more than MEMORY_TARGET

When logging in to the database, you will be prompted that the database listening does not exist

Log in to the oracle account and log in to the database server to check whether the database monitoring is enabled

lsnrctl status Check the database monitoring, the result is as follows, the database service is not started.

SQL>startupSqlplus / as sysdba sqlplus interface login as dba

Start the database, the error message is

SGA_MAX_SIZE 536870912 cannot be set to more than MEMORY_TARGET 411041792

Problem analysis : In Oracle 11g, MAX(SGA+PGA)<= memory_target, when SGA is greater than memory_target, an exception may occur when using startup nomount

Processing steps: At this time, the following steps need to be performed:

SQL> create pfile=’/home/oracle/init0321.ora’ from spfile;

File created.

SQL> !vi /home/oracle/init0321.ora

Then modify:

*.memory_target=1073741824

*.sga_max_size=805306368

*.sga_target=805306368

SQL> startup pfile=’/home/oracle/init0321.ora’;

SQL> create spfile from pfile=’/home/oracle/init0321.ora’;

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup;

The database starts normally, and you can log in to the database using the tool normally.

[Solved] yarn: Unable to load the File C:\Users\Administrator\AppData\Roaming\npm\yarn.ps1, Because running scripts is prohibited on this system.

Problem Description: yarn is used in vscode terminal to report an error

Specific error information:

yarn: Unable to load the File C:\Users\Administrator\AppData\Roaming\npm\yarn.ps1, Because running scripts is prohibited on this system. For more information, please refer to https:/go.microsoft.com/fwlink/?LinkID=135170
About_Execution_Policies.
Location Line: 1 Character: 1
+ ~~~~
    + CategoryInfo          : SecurityError: (:) [],PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

Solution:

1. Open windows PowerShell in administrator mode (the general shortcut key win + X can wake up for selection)

2. Enter get executionpolicy in PowerShell and return restricted

3. PowerShell input set executionpolicy remotesigned

4. PowerShell returns the result and enters y for setting

Execute policy changes
Execution strategies can help you prevent the execution of untrusted scripts. Changing the execution strategy may create security risks, such as https:/go.microsoft.com/fwlink/?LinkID=135170
As described in the about_Execution_Policies help topic. Do you want to change the execution strategy?
[Y] Yes (Y) [A] All Yes (A) [N] No (N) [L] All No (L) [S] Pause (S) [?] Help (default is "N"):

[Solved] C++ get file size via ifstream and set mode as ios::ate

void getSize21()
{
    ifstream wFile;
    wFile.open("log3.txt",ios::ate);
    if(!wFile.is_open())
    {
        cout<<"Open log3.txt failed!"<<endl;
    }
    streampos size;    
    size=wFile.tellg();
    cout<<"Size="<<size<<endl;
    cout<<"Finished in getSize21() and now is "<<getTimeNow()<<endl;
}

The key located at set ios::ate,ate stands for at end.
Then when size=wFile.tellg();

void getFileSize19()
{
    streampos begin,end;
    ifstream rFile("log3.txt",ios::in);
    if(!rFile.is_open())
    {
        cout<<"Open log3.txt failed!"<<endl;
    }

    begin=rFile.tellg();
    cout<<"Begin is "<<begin<<endl;
    rFile.seekg(0,ios::end);
    end=rFile.tellg();
    cout<<"End is "<<end<<endl;
    rFile.close();
    cout<<"Size is "<<(end-begin)<<" bytes"<<endl;
}

java.lang.nullpointerexception: cannot unbox null value [How to Solve]

Solution: first, locate the key sentence according to the error report

list<charginPileVO>......

Then the breakpoint and add this sentence to watch will show a real exception: Java.Lang.nullpointerexception: cannot unbox null value
because the object is empty when unpacking, an error is reported when unpacking. The basic type from integer object to int will be unpacked automatically. And integer is empty, so an error is reported

max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

Error when elasticsearch is started:

max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

It means that the value of the virtual memory limit is set too small, at least 262144

Temporary method:

sysctl -w vm.max_map_count=262144

Permanent method:

vim /etc/sysctl.conf

Add a row:

vm.max_map_count=262144

Update configuration

sysctl -p

[Solved] Error: unable to find or load main class org.apache.zookeeper.server.quorum.QuorumPeerMain

About zoomeeper decompressing the compressed package in windows, an error occurs when starting zoomeeper

Error: unable to find or load main class org apache.zookeeper.server.quorum.QuorumPeerMain

Eliminate the data path problem. The error is that the class package cannot be found and the jar package folder lib is missing

To solve the problem, first configure the directory where the configuration file data is stored, and copy and modify it in the conf folder

Modify data path

The key to error reporting is

The first one has no lib files. You need to unzip the second one, copy and paste lib into the zookeeper directory where the first one is unzipped.

[Solved] Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean (default-clean)

When compiling a java program using Maven’s Tomcat control, the error {failed to execute goal Is reported org.apache.maven.plugins:maven-clean-plugin:2.5:clean (default-clean) on project **-web: Failed to clean project: Failed to delete E:\**\target\tomcat\logs\access_log

Such errors

This error usually occurs because you have started another Tomcat process or run javaw Exe process, resulting in an error.

Solution:

1. Click x to close the failed console page (if it is run multiple times, the program console will only be placed here)

After closing, you should see the small red square. Click to make the Tomcat process or run javaw Exe process stopped.

Just recompile.

——————————–

If the above is not enough, go to the task manager} process to find the process (the last column is the name), end this, and then run the project.