Author Archives: Robins

The following sections have been defined but have not been rendered for the layout page “~/views/shared/_layout.cshtml”: “footscript”

The error contents are as follows:

Method 1:

1. In the _Layout.cshtml layout body, add section, Scripts.Render and RenderSection tag sample code as follows:
<body class=”bodyBg font_fm”>
    <section>
        @RenderBody()
    </section>
    @Scripts.Render(“~/bundles/jquery”)
    @RenderSection(“scripts”, required: false)
</body>
2. In the content view to be used, use the section tag to put everything in the form in the section, you can
Method 2:

When searching on the Internet, there will be a lot of the first method, but I used it in my code but it was of no use.

After searching for a long time, I found the second one. Before using the second one, delete the first one, otherwise an error “Reuse RenderBody method” will be reported.

But the first one may be solved if some people use it, just because of the code.

How to Solve Spring Bean Same Name Conflict

When springboot is started, it often fails to start. It is found that there are services and serviceimpl with the same name under different packages. It is reasonable to say that there can be classes with the same name under different packages, but it cannot be started. An error is reported

org. springframework. context. annotation. ConflictingBeanDefinitionException: Annotation-specified bean name ‘roleServiceImpl’ for bean class [com.example.service.RoleServiceImpl] conflicts with existing, non-compatible bean definition of same name and class [com.example.roleService.RoleServiceImpl]

Meaning: the class [com. Example. Service. Roleserviceimpl] annotated with bean name ‘roleserviceimpl’ conflicts with the existing incompatible class with the same name [com.Example.Roleservice.Roleserviceimpl].

It turns out that the annotation @service is only used on these two implementation classes. According to the mapping rules, these two services are mapped to roleserviceimpl, which conflicts.

Solution:

1. change one of the implementation classes to a different name;

2: change one of the annotations to an annotation @service (name = “AAAA”) whose name is non roleserviceimpl.

Start again, OK.

[Solved] Vue3 Import Cutomize Components Error: Cannot find module ‘xxx‘ or its corresponding type declarations

1. Error reporting

1. Error reported in idea

2. Scaffold compilation error

2. Cause

There is no problem with the statements. Why do you report errors? Because the address of Import is wrong.

Solution:

import TheHeader from '../components/the-header.vue';
import TheFooter from "../components/the-footer.vue";
import TheSider from "../components/the-sider.vue";

3. The effects are as follows:

Perfect solution.

ERROR in ch.qos.logback.core.joran.spi.Interpreter@73:41 – no applicable action for [AppenderRef], current ElementPath is [[Configuration][Loggers][Root][AppenderRef]]

1. Error reason

Springboot introduces rocketmq spring boot starter and reports an error

 

 

2. Solution – exclude dependencies

        <dependency>
            <groupId>org.apache.rocketmq</groupId>
            <artifactId>rocketmq-spring-boot-starter</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

 

Project started successfully

 

[Solved] Error running ‘xyp’: Unable to open debugger port (127.0.0.1:56767): java.net.BindException “Address already in use: NET_Bind

When the web project is running, the idea may report error running ‘Tomcat’: unable to open debugger port (127.0.0.1:56767): Java net. Socketexception “socket closed” error, unable to start Tomcat
at this time, you need to find the occupied port and end the task!

Step 1: open the DOS command window. Enter netstat – ano or netstat – ano | find “56767”

Find the PID number corresponding to the port

Step 2: open task management (Ctrl + x)

Find the PID corresponding task “end task” in “details”

Perfect solution!

[Solved] NodeNotFoundError(self.error_message, self.key, origin=self.origin) django.db.migrations.excep

Error code:

raise NodeNotFoundError(self.error_message, self.key, origin=self.origin)
django.db.migrations.exceptions.NodeNotFoundError: Migration jobs.0001_initial dependencies reference nonexistent parent node ('auth', '0012_alter_user_first_name_max_length')

Solution:

The first step is to uninstall Django, PIP uninstall Django
the second step is to delete the remaining Django folder in the/lib/site packages package
the third step is to delete all pycache folders in the project, delete files under migrations, and retain init py.
Step 3: reinstall the corresponding version of Django, otherwise some will be incompatible.
Step 4: execute the migration. Success

[Solved] VUE Project Error: Avoided redundant navigation to current location: “/XXX“

In Vue, the router encounters an error: avoided redundant navigation to current location: the error message shows that the route is duplicate

Solution: add the following code to get it done Under router folder index.js

// Solve the problem that vue-router in the navigation bar of ElementUI reports an error when repeatedly clicking the menu in version 3.0 or above
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

[Solved] MYSQL Command gruop by Error: this is incompatible with sql_mode=only_full_group_by

Error Messages:
ERROR 1055 (42000): Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column ‘student.name’ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

Check the version of MYSQL

select version();

View the Content in SQL_mode

select @@GLOBAL.sql_mode;

Reason:

The only_full_group_by option is enabled by default in mysql5.7 and above. My version is mysql5.7.27

Take a look at the syntax of group by:

select select the column in the group + aggregate function from the table name group by grouped column

From the perspective of grammatical format, the grouping is first established, and then the columns to be retrieved are determined. The columns to be retrieved can only be selected from the columns participating in the grouping.

My current Mysql version 5.7.27,

Let’s look at the meaning of ONLY_FULL_GROUP_BY: For the GROUP BY aggregation operation, if the column in the SELECT does not appear in the GROUP BY, then this SQL is illegal, because the column is not in the GROUP BY clause, that is to say, it is detected List

It must appear after the group by, otherwise an error will be reported, or this field appears in the aggregate function.

 

There are two solutions. The first is to temporarily solve the problem, which will reappear when the database is restarted, and the second is to modify the MySQL configuration file

Windows solution:

Method 1:
Delete ONLY_FULL_GROUP_BY in the queried sql_mode, it will be invalid after restart

set @@GLOBAL.sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';

Method 2:
find your MySQL installation path first

select @@basedir;

Then go to the folder and find your my Ini configuration file, modify the content in [mysqld], add the following content, then exit the database and restart MySQL in the service

sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION

Linux solution:

Method 1:
Delete ONLY_FULL_GROUP_BY in the queried sql_mode, it will be invalid after restart

set @@GLOBAL.sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';

Method 2:
The configuration file of mysql on linux is not called my.ini, the configuration file is in /etc/my.cnf

vim /etc/my.cnf

Modify the content in [mysqld], add the following content, and then restart mysql

sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION

Restart command:

service mysql restart

[Solved] SQL Server Error: Cannot drop database XXX because it is currently in use

I encountered this problem when using pymssql to connect to SQL Server.

pymssql.OperationalError: (3702, b'Cannot drop database "XXX" because it is currently in use.DB-Lib error message 20018, severity 16:\nGeneral SQL Server error: Check messages from the SQL Server\n')
1
Programmer:

 	cursor = conn.cursor()
    conn.autocommit(True)
    cursor.execute('CREATE DATABASE XXX ON (NAME=\'XXX_Data\', FILENAME=\'{}\\XXX.mdf\', SIZE=5 MB, MAXSIZE=50 MB, FILEGROWTH=5%) LOG ON (NAME=\'XXX_Log\',FILENAME=\'{}\\XXX_Log.ldf\',SIZE=1 MB,MAXSIZE=5 MB,FILEGROWTH=1 MB)'.format(dir, dir))
    cursor.execute('USE XXX CREATE TABLE xxx ( xxxxxxx )')
    cursor.execute('DROP TABLE xxx')
    cursor.execute('USE XXX DROP DATABASE XXX')

I turned on autocommit before operating the database, and then found that if I performed other operations on the database between the CREATE DATABASE and DROP DATABASE statements, the above error would occur when DROP DATABASE.
After checking the relevant information, I found that the reason is that the database itself is used incorrectly when deleting the database: "USE XXX", in order to delete successfully, you need to change the USE to "USE MASTER": cursor.execute(cursor)

cursor.execute('USE MASTER DROP DATABASE XXX')
1
Then the deletion is successful.

Another method on the Internet is to add the following statement to roll back the database to the initial state, the actual test did not affect me, the reason is unknown.

use master
go
alter database database_name set single_user with rollback immediate 
 

Moved online, effective

IDEA compile error: sun.misc.Base64decoder upgrade processing

Idea compile error report sun.misc.BASE64Decoder upgrade processing
warn:
17:01:15 /deploy/jenkins/workspace/auto-java-test/utils/ImageBase64Utils.java:67: warning: BASE64Encoder is internal proprietary API and may be removed in a future release
17:01:15 BASE64Encoder encoder = new BASE64Encoder();
import sun.misc.BASE64Decoder;
Alternative writing:
//Since JDK 1.8, the JDK public APIs of java.util.Base64.Decoder and java.util.Base64.Encoder have been provided, which can replace the JDK internal APIs of sun.misc.BASE64Decoder and sun.misc.BASE64Encoder.
//byte[] bytes = new BASE64Decoder().decodeBuffer(base64);
byte[] bytes = Base64.getDecoder().decode(base64);

//Or use method
import org.apache.commons.codec.binary.Base64;
return Base64.encodeBase64String(encrypted);

demo test class

@Test
    public void test2() throws Exception{
        //Decoder and java.util.Base64.Encoder are available from JDK 1.8 onwards, replacing the internal JDK APIs of sun.misc. .
        //byte[] bytes = new BASE64Decoder().decodeBuffer(base64);

        System.out.println("-----------------------Early Write ----------------------");
        String text = "String text";
         BASE64Encoder encoder = new BASE64Encoder();
         BASE64Decoder decoder = new BASE64Decoder();
         byte[] textByte = text.getBytes("UTF-8");
        //Code
         String encodedText = encoder.encode(textByte);
        System.out.println(encodedText);
        //Decoding
        System.out.println(new String(decoder.decodeBuffer(encodedText), "UTF-8"));

        /**
         * Compared with the Base64 codecs provided by sun.mis c suite and Apache Commons Codec, the Base64 provided by Java 8 has better performance. In the actual test of encoding and decoding speed, Base64 provided by Java 8 is at least 11 times faster than that provided by sun.mis c suite and at least 3 times faster than that provided by Apache Commons Codec. So if you want to use Base64 in Java, the Base64 category provided by the java .util package under Java 8 is definitely the first choice!
         * https://blog.csdn.net/zhou_kapenter/article/details/62890262
         */
        System.out.println("-----------------------New writing style----------------------");
        byte[] test11 = Base64.getEncoder().encode(textByte);
        System.out.println("test11_string="+new String(test11, "UTF-8"));
        byte[] bytes11 = Base64.getDecoder().decode(test11);
        System.out.println("test11="+new String(bytes11, "UTF-8"));

        System.out.println("-----------------------apache writing style----------------------");
        String test22 = org.apache.tomcat.util.codec.binary.Base64.encodeBase64String(textByte);
        System.out.println("test22_string="+test22);
        byte[] bytes22 = org.apache.tomcat.util.codec.binary.Base64.decodeBase64(test22);
        System.out.println("test22="+new String(bytes22, "UTF-8"));

        /**
         * Print results: Consistent results
         * ----------------------- early write ----------------------
         * 5a2X5Liy5paH5a2X
         * String text
         * ----------------------- new write ----------------------
         * test11 string = 5a2X5Liy5paH5a2X
         * test11=string literal
         * -----------------------apache writeup ----------------------
         * test22 string=5a2X5Liy5paH5a2X
         * test22=word string literal
         */
    }