Tag Archives: development language

[Solved] fasterxml ToStringSerializerBase Error: Caused by: java.lang.NoClassDefFoundError…

Tostringserializerbase reports an error

Error content

Integration Dubbo times error

Caused by: java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/ser/std/ToStringSerializerBase
	at com.fasterxml.jackson.datatype.jsr310.JavaTimeModule.<init>(JavaTimeModule.java:158) ~[jackson-datatype-jsr310-2.13.2.jar:2.13.2]
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_322]
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_322]
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_322]
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_322]
	at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:211) ~[spring-beans-5.3.18.jar:5.3.18]
	... 69 common frames omitted

reason

Dubbo dependency needs the support of fasterxml

        <dependency>
            <groupId>org.apache.dubbo</groupId>
            <artifactId>dubbo-spring-boot-starter</artifactId>
            <version>3.0.7</version>
        </dependency>

        <dependency>
            <groupId>org.apache.dubbo</groupId>
            <artifactId>dubbo-rpc-dubbo</artifactId>
            <version>3.0.7</version>
        </dependency>

        <dependency>
            <groupId>org.apache.dubbo</groupId>
            <artifactId>dubbo-registry-zookeeper</artifactId>
            <version>3.0.7</version>
        </dependency>

solve

Add dependency

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>2.10.1</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.10.1</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <version>2.10.1</version>
        </dependency>

Complete dependency

    <dependencies>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>2.10.1</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.10.1</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <version>2.10.1</version>
        </dependency>


        <dependency>
            <groupId>org.apache.dubbo</groupId>
            <artifactId>dubbo-spring-boot-starter</artifactId>
            <version>3.0.7</version>
        </dependency>

        <dependency>
            <groupId>org.apache.dubbo</groupId>
            <artifactId>dubbo-rpc-dubbo</artifactId>
            <version>3.0.7</version>
        </dependency>

        <dependency>
            <groupId>org.apache.dubbo</groupId>
            <artifactId>dubbo-registry-zookeeper</artifactId>
            <version>3.0.7</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>2.6.6</version>
        </dependency>

        <dependency>
            <groupId>org.example</groupId>
            <artifactId>common</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>

    </dependencies>

 

[Solved] jooq Customize GeneratorStrategy Error: ClassNotFoundException

Problem description

tip: describe the problems encountered in the project here:

Gradle (kotlin project)

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jooq.codegen.GenerationTool
import org.jooq.meta.jaxb.*

plugins {
    id("org.springframework.boot") version "2.7.1"
    id("io.spring.dependency-management") version "1.0.11.RELEASE"
    kotlin("jvm") version "1.6.21"
    kotlin("plugin.spring") version "1.6.21"

}

group = "com.nova"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_1_8

repositories {
    mavenCentral()
}

buildscript {
    repositories {
        mavenLocal()
        mavenCentral()
    }
    dependencies {
        classpath("org.jooq:jooq-codegen:3.14.7")
        classpath("mysql:mysql-connector-java:8.0.29")
    }
}


dependencies {

    implementation("org.springframework.boot:spring-boot-starter-jooq")
    implementation("org.springframework.boot:spring-boot-starter-web")
    implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
    implementation("org.jetbrains.kotlin:kotlin-reflect")
    implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
    runtimeOnly("mysql:mysql-connector-java:8.0.29")
    testImplementation("org.springframework.boot:spring-boot-starter-test")
    implementation("org.jooq:jooq:3.14.7")
    implementation("org.jooq:jooq-meta:3.14.7")
    implementation("org.jooq:jooq-codegen:3.14.7")

}

tasks.register("JOOQ_Code_Generate") {
    doLast{
        val config: org.jooq.meta.jaxb.Configuration = Configuration()
            .withJdbc(Jdbc()
                .withDriver("com.mysql.cj.jdbc.Driver")
                .withUrl("jdbc:mysql://127.0.0.1:3306/learn-jooq?characterEncoding=UTF-8&serverTimezone=GMT")
                .withUsername("root")
                .withPassword("root"))
            .withGenerator(Generator()
                    //default is java
                .withName("org.jooq.codegen.KotlinGenerator")
                .withGenerate(Generate()
                    .withComments(true) 
                    .withCommentsOnCatalogs(true)
                    .withRelations(true)
                    .withImmutablePojos(false) // if true, cannot use 'into()' method
                    .withInterfaces(true)
                    .withDaos(true))
                .withDatabase(Database()
                    .withName("org.jooq.meta.mysql.MySQLDatabase")
                    .withIncludes("s.*")
                    .withInputSchema("learn-jooq")
                )
                .withTarget(org.jooq.meta.jaxb.Target()
                    .withPackageName("com.nova.novademo.codegen")
                    .withDirectory("src/main/kotlin"))
                .withStrategy(Strategy() //Customized generation policy, error reporting
                    .withName("com.nova.novademo.CustomGeneratorStrategy")
//                    .withName("org.jooq.codegen.DefaultGeneratorStrategy")
                )
            )
        GenerationTool.generate(config)
    }
}


tasks.withType<KotlinCompile> {
    kotlinOptions {
        freeCompilerArgs = listOf("-Xjsr305=strict")
        jvmTarget = "1.8"
    }
}

tasks.withType<Test> {
    useJUnitPlatform()
}

Maven (Java project)

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.6.4</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.lzy</groupId>
    <artifactId>JOOQ</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>JOOQ</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jooq</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jooq</groupId>
            <artifactId>jooq-meta</artifactId>
            <version>3.14.15</version>
        </dependency>
        <dependency>
            <groupId>org.jooq</groupId>
            <artifactId>jooq-codegen</artifactId>
            <version>3.14.15</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>


            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>


            <!-- jooq code generate plugin-->
            <plugin>

                <groupId>org.jooq</groupId>
                <artifactId>jooq-codegen-maven</artifactId>
                <version>${jooq.version}</version>
                
                <configuration>
                    <jdbc>
                        <driver>com.mysql.cj.jdbc.Driver</driver>
                        <url>jdbc:mysql://127.0.0.1:3306/learn-jooq?serverTimezone=GMT%2B8</url>
                        <user>root</user>
                        <password>root</password>
                    </jdbc>
                    <generator>
                        <strategy>
                            <name>com.lzy.jooq.CustomGeneratorStrategy</name>
                        </strategy>
                        <generate>
                            <pojos>true</pojos>
                            <daos>true</daos>
                        </generate>
                        <database>
                            <includes>s.*</includes>
                            <inputSchema>learn-jooq</inputSchema>
                        </database>
                        <target>
                            <packageName>com.lzy.jooq.codegen</packageName>
                            <directory>/src/main/java</directory>
                        </target>
                    </generator>
                </configuration>
            </plugin>

        </plugins>
    </build>

</project>



Cause analysis:

After specifying the GeneratorStrategy as a custom CustomGeneratorStrategy, an error ClassNotFoundException is reported.


Solution:

You can compile or run it first, as long as you generate the corresponding .class file under the target file.

[Solved] nacos Startup Error: Please set the JAVA_HOME variable in your environment

Nacos is registered as a service in centos7, but it cannot be started

report errors

Please set the JAVA_HOME variable in your environment, We need java(x64)! jdk8 or later is better!

reason

The java and javac of the installed JDK are not in the nacos startup script startup.sh (mine is under /opt/java/jdk1.8.0_333/)

terms of settlement

Add Java path to startup.sh

[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=/opt/java/jdk1.8.0_333

Restart the service successfully

[Solved] MVN Build Project Error: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M5:test

Error Messages:

Failed to execute goal
org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M5:test

[INFO] --- maven-surefire-plugin:3.0.0-M5:test (default-test) @ wls-exporter-core ---
Oct 16, 2021 7:34:54 AM org.sonatype.guice.bean.reflect.Logs$JULSink warn
WARNING: Error injecting: org.apache.maven.plugin.surefire.SurefirePlugin
com.google.inject.ProvisionException: Guice provision errors:

1) No implementation for org.codehaus.plexus.languages.java.jpms.LocationManager was bound.
  while locating org.apache.maven.plugin.surefire.SurefirePlugin

1 error
        at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1006)
        at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1032)
        at org.sonatype.guice.bean.reflect.AbstractDeferredClass.get(AbstractDeferredClass.java:45)
        at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:86)
        at com.google.inject.internal.InternalFactoryToInitializableAdapter.provision(InternalFactoryToInitializableAdapter.java:55)
        at com.google.inject.internal.ProviderInternalFactory$1.call(ProviderInternalFactory.java:70)
        at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:100)
        at org.sonatype.guice.plexus.lifecycles.PlexusLifecycleManager.onProvision(PlexusLifecycleManager.java:138)
        at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:109)
        at com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:55)
        at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:68)
        at com.google.inject.internal.InternalFactoryToInitializableAdapter.get(InternalFactoryToInitializableAdapter.java:47)
        at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:997)
        at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1047)
        at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:993)
        at com.google.inject.Scopes$1$1.get(Scopes.java:59)
        at org.sonatype.guice.bean.locators.LazyBeanEntry.getValue(LazyBeanEntry.java:83)
        at org.sonatype.guice.plexus.locators.LazyPlexusBean.getValue(LazyPlexusBean.java:49)
        at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:253)
        at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:245)
        at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:455)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:92)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:414)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:357)

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.410s
[INFO] Finished at: Sat Oct 16 07:34:54 UTC 2021
[INFO] Final Memory: 21M/154M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M5:test (default-test) on project wls-exporter-core: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M5:test failed: Unable to load the mojo 'test' (or one of its required components) from the plugin 'org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M5': com.google.inject.ProvisionException: Guice provision errors:
[ERROR]
[ERROR] 1) No implementation for org.codehaus.plexus.languages.java.jpms.LocationManager was bound.
[ERROR] while locating org.apache.maven.plugin.surefire.SurefirePlugin
[ERROR] at ClassRealm[plugin>org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M5, parent: sun.misc.Launcher$AppClassLoader@7852e922]
[ERROR] while locating org.apache.maven.plugin.Mojo annotated with @com.google.inject.name.Named(value=org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M5:test)
[ERROR]
[ERROR] 1 error
[ERROR] role: org.apache.maven.plugin.Mojo
[ERROR] roleHint: org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M5:test

Solution

Upgrade maven to the latest version

Reference:
https://stackoverflow.com/questions/53211941/unable-to-load-the-mojo-test-org-apache-maven-pluginsmaven-surefire-plugin

Error message
maven plugin failed to parse: Could not transfer artifact XXX, transfer failed for XXX
Solution:
Finally add this to the maven parameters to solve the certificate problem on the line.
-Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true

[Solved] webpack Package Error: ERROR in multi ./src/main.js ./dist/bundle.js Module not found: Error: Can‘t resolv

When I first came into contact with webpack, I encountered several problems. After successfully installing the latest version of webpack and cli, there was a problem with the first package. In fact, it was also a syntax error

When running webpack .\src\main.js .\dist\bundle.js and packaging, the following error occurs:

Cause of error:

The latest version of the webpack command has changed

Solution:

Add a -o to the previous command.
run webpack .\src\main.js -o .\dist\bundle.js

[Solved] jar Run Error: no main manifest attribute

Jar running error no main manifest attribute

Solution:

After investigation, it was found that it was pom.xml is not added in Maven project:

<packaging>jar</packaging>

And the following configurations:

<build>
<!--maven-->
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
  <resources>
  <!-- pom.xml resources -->
    <resource>
      <directory>src/main/java</directory>
      <includes>
        <include>**/*.properties</include>
      </includes>
    </resource>
    <resource>
      <!-- The *.xml file in the java directory will also be packaged when the project is packaged -->
      <directory>src/main/resources</directory>
    </resource>
    <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
                <filtering>false</filtering>
            </resource>
  </resources>
</build>

[Solved] C++ reason ncnn model error: Segmentation fault (core dumped)

The reasoning code is as follows:

#include "net.h"
#include <iostream>
#include <fstream>
#include <algorithm>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <stdio.h>
#include <vector>
#include <opencv2/opencv.hpp>

using namespace std;

void pretty_print(const ncnn::Mat& m)
{
    for (int q=0; q<m.c; q++)
    {
        const float* ptr = m.channel(q);
        for (int y=0; y<m.h; y++)
        {
            for (int x=0; x<m.w; x++)
            {
                printf("%f ", ptr[x]);
            }
            ptr += m.w;
            printf("\n");
        }
        printf("------------------------\n");
    }
}
//main fuction
int main(){
    string img_path = "person1.jpeg";
    cv::Mat img = cv::imread(img_path, cv::IMREAD_COLOR);
    cv::Mat img2;
    int input_width = 512;//Input size specified when going onnx
    int input_height = 512;
    
    cv::resize(img, img2, cv::Size(input_width, input_height));
  

    // Load the converted and quantized alexnet network
    ncnn::Net net;
    // net.opt.num_threads=1;
    net.load_param("cps_simplif.param");
    net.load_model("cps_simplif.bin");
    // Convert opencv mat to ncnn mat
    ncnn::Mat input = ncnn::Mat::from_pixels(img2.data, ncnn::Mat::PIXEL_BGR, img2.cols, img2.rows);
    const float mean_vals[3] = {0.485, 0.456, 0.406};
    const float norm_vals[3] = {0.229, 0.224, 0.225}; //[0.485, 0.456, 0.406]),std=np.array([0.229, 0.224, 0.225]
    input.substract_mean_normalize(mean_vals, norm_vals);
    // ncnn forward calculation
    ncnn::Extractor extractor = net.create_extractor();
    extractor.input("input.1", input);
    ncnn::Mat output0;
    extractor.extract("1035", output0);

    //ncnn::mat ->>>>> cv::mat
    cv::Mat a(input_height,input_width, CV_8UC3);
    output0.to_pixels(a.data, ncnn::Mat::PIXEL_BGR2RGB);
    
    cv::imwrite("ncnninfer.png", a);
    
    // pretty_print(output0);
    // pretty_print(output1);

    cout<<"done"<<endl;
    return 0;
}

Only segmentation fault (core dumped) is reported after running

No core file is generated. Check through ulimit -c, the size of core file is unlimited and there is no problem. This method solves the problem of not generating core file

With core file

Pass under the terminal

apt-get update
apt-get install gdb

Install GDB

Installation completed, passed

gdb ./Execution file name   core

The core here can be modified according to its own core file name.
the error is found at:

Corresponding to the reasoning code above

output0.to_pixels(a.data, ncnn::Mat::PIXEL_BGR2RGB);

It is the code to realize the conversion from ncnn:: mat to cv:mat. After debugging, it is found that the reasoning results of ncnn are all Nan, which leads to the conversion failure

Adjust the previous input, normalization is not done well.

[Solved] JAVA OpenCV Startup Error: java.lang.UnsatisfiedLinkError

About using OpenCV for image processing and image recognition technology,

there are few examples involving Java.
after introducing lib and DLL according to online operations, an error Java is reported Lang.unsatisfiedlinkerror
Someone said they would add system loadLibrary(Core.NATIVE_LIBRARY_NAME); Otherwise, it will report an error java Lang.unsatisfiedlinkerror
but it still report error: java.lang.UnsatisfiedLinkError

Solution: (my operating system is windows64 bit)
Copy the downloaded dll file under opencv\build\java\x64 to C:\Windows\System32


then go to idea to start the main method, and there will be no errors.

python chatterbot [nltk_data] Error loading stopwords: <urlopen error [Errno 11004]

The following error occurred while running the project:

[nltk_data] Error loading stopwords: <urlopen error [Errno 11004]
[nltk_data]     getaddrinfo failed>
[nltk_data] Error loading averaged_perceptron_tagger: <urlopen error
[nltk_data]     [Errno 11004] getaddrinfo failed>

The Solution is as follows:

Go to: https://github.com/nltk/nltk_data

Go to the directory /packages/corpora/ and find the corresponding file stopwords.zip and put it under the corresponding file

It is recommended that the entire nltk_data project is downloaded with a size of 695M to avoid other problems that cannot be downloaded!

Extract the zip file

nltk_data-gh-pages.zip\nltk_data-gh-pages\packages

all files to the following directory

C:\Users\Administrator\AppData\Roaming\nltk_data

Here the installation directory may be different for each person, here I am in the above directory.

Modify the corresponding file.

\venv\Lib\site-packages\chatterbot\utils.py under the current project directory

(Some children’s directory may not be under the current project, you can find the corresponding site-packages directory according to your own configuration and then find the corresponding files to modify)

The corresponding code nltk_download_corpus(‘xxx’) needs to be modified as follows:


def download_nltk_stopwords():
    """
    Download required NLTK stopwords corpus if it has not already been downloaded.
    """
    nltk_download_corpus('corpora/stopwords')


def download_nltk_wordnet():
    """
    Download required NLTK corpora if they have not already been downloaded.
    """
    nltk_download_corpus('corpora/wordnet')


def download_nltk_averaged_perceptron_tagger():
    """
    Download the NLTK averaged perceptron tagger that is required for this algorithm
    to run only if the corpora has not already been downloaded.
    """
    nltk_download_corpus('taggers/averaged_perceptron_tagger')


def download_nltk_vader_lexicon():
    """
    Download the NLTK vader lexicon for sentiment analysis
    that is required for this algorithm to run.
    """
    nltk_download_corpus('sentiment/vader_lexicon')

Done!

[Solved] Crypto-JS Failed to Decrypt Error: Uncaught Error: Malformed UTF-8 data

java encrypt js decrypt, an error is reported: Uncaught Error: Malformed UTF-8 data

public static String encrypt(String strToEncrypt, SecretKey secretKey) {
    try {
      Cipher cipher = Cipher.getInstance("AES/ECB/PKCS7PADDING");
      cipher.init(Cipher.ENCRYPT_MODE, secretKey);
      encryptedString = new String(Base64.encodeBase64String(cipher.doFinal(strToEncrypt.getBytes())));
    } catch (Exception e) {
      System.out.println("Error while encrypting: " + e.toString());
    }

    return encryptedString;
  }

JS:

decrypt(secret_key,code) {
        return CryptoJS.AES.decrypt(code, this.parse(secret_key), {
          mode: CryptoJS.mode.ECB,
          padding: CryptoJS.pad.Pkcs7
        }).toString(CryptoJS.enc.Utf8);
      }

The reason is that the string has a newline character, Base64 generates a newline, change to NO_WRAP

 Base64.encodeBase64String(hashPassword,Base64.NO_WRAP)

Recommended Read: https://stackoverflow.com/questions/21852889/remove-r-and-n-from-aes-encrypted-string

 

How to Solve Error: Error parsing mapper XML

[Solved] Error parsing Mapper XML

Error parsing mapper xml
this error message is essentially a mapper XML error
failed resolve xxx XML, etc.
here we analyze some problems that will not become popular when writing, and that will cause errors when starting

1. ID conflict

The conflicts here are
resultmap

<resultMap type="com.newtouch.business.module.dto.T01agentComDTO" id="t01agentComMap">

<resultMap type="com.cpi.newtouch.business.module.dto.T01comDTO" id="t01agentComMap">

Specific SQL

<select id="findBy" >
<update id="findBy">

As long as two or more IDs are the same, an error will be reported. This usually happens because you don’t pay attention to copy and paste. You need to be careful!

2. Return type error

<resultMap type="com.newtouch.business.module.dto.T01agentComDTO" id="t01agentComMap">
<select id="findBy" resultType="t01agentComMap">

Like here, I returned the resultmap, but wrote the resulttype

Similarly, for example, if I return a string type, but I write a resultmap, I will also report an error

3. Not writing the full class name

<resultMap type="com.newtouch.business.module.dto.T01agentComDTO" id="t01agentComMap">

The resultmap, if I write it like this

<resultMap type="T01agentComDTO" id="t01agentComMap">

An error will be reported. Of course, if relevant settings are configured

[Solved] Golang Error: main.go:5:2: package go_code/chapter10/factory/model is not in GOROOT

golang Error: is not in GOROOT

The following errors are reported during operation

PS C:\goproject\src\go_code\chapter10\factory\main> go run main.go
main.go:5:2: package go_code/chapter10/factory/model is not in GOROOT (C:\go\src\go_code\chapter10\factory\model)

The process is as follows

PS C:\goproject\src\go_code\chapter10\factory\main> go run main.go
main.go:5:2: package go_code/chapter10/factory/model is not in GOROOT (C:\go\src\go_code\chapter10\factory\model)

PS C:\goproject\src\go_code\chapter10\factory\main>  go env
set GO111MODULE=

PS C:\goproject\src\go_code\chapter10\factory\main> go env -w GO111MODULE=off
PS C:\goproject\src\go_code\chapter10\factory\main> go run main.go
{tom 78.9}