Tag Archives: back-end

[Solved] docker Error response from daemon OCI runtime create failed container_linux.go380

docker: Error response from daemon: OCI runtime create failed: container_ linux. Go:380 error 

Docker fails to run after installing mysql5.7, and reports error: OCI runtime create failed

Pull mysql5.7 on docker is OK
execute the code and report an error

docker run -p 3306:3306 --name mysql 

-v /mydata/mysql/log:/var/log/mysql
-v /mydata/mysql/data:/var/lib/mysql
-v /mydata/mysql/conf:/etc/mysql
-e MYSQL_ ROOT_ PASSWORD=root
-d mysql:5.7

cd to /mydata/mysql/conf and finds that it is not mounted correctly, and there is no /etc/mysql file path

Reason for error: because of the compatibility between Linux and docker version, the docker version needs to be degraded or reinstalled

There are two solutions:

  1. Reinstall the specified version of docker
  2. Downgrade docker to the specified version

The first method: uninstall and reinstall:

//Step 1: Uninstall docker

//List the packages downloaded by docker
sudo yum list installed | grep docker

//remove all the above related installed packages sudo yum -y remove "above show related packages"
sudo yum -y remove docker-ce.x86_64
sudo yum -y remove docker-ce-cli.x86_64

// Remove related images and containers
sudo rm -rf /var/lib/docker

sudo yum remove docker 
              docker-client 
              docker-client-latest 
              docker-common 
              docker-latest 
              docker-latest-logrotate 
              docker-logrotate 
              docker-selinux 
              docker-engine-selinux 
              docker-engine
                 
//Test for deletion
docker -v


// Step 2: reinstall the specified version of docker

// Install some necessary system tools.
sudo yum install -y yum-utils device-mapper-persistent-data lvm2

// Add software source information: sudo yum-config -y
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

//Update the yum cache.
sudo yum makecache fast

//View the available versions of Docker-ce: sudo yum list docker-ce
yum list docker-ce --showduplicates | sort -r

// If you need to show only table versions, you can turn off the list for test versions: yum list
sudo yum-config-manager --enable docker-ce-edge
sudo yum-config-manager --enable docker-ce-test

//Update the yum package index
yum makecache fast

//Install the specified version of docker-ce: sudo yum install -y docker-ce
sudo yum install -y docker-ce-17.03.2.ce-1.el7.centos 

// Error: If the installation of the specified version of docker shows that the specified version of the docker-ce-selinux dependency package needs to be installed, please install.
yum install -y https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-selinux-17.03.2.ce-1.el7.centos.noarch.rpm 

Then pull MySQL again

docker pull mysql:5.7

The second method: downgrade docker to the specified version:

//stop docker
sudo systemctl stop docker
//Enter the downgrade command
yum downgrade --setopt=obsoletes=0 -y docker-ce-17.03.2.ce-1.el7 docker-ce-selinux-17.03.2.ce-1.el7 containerd.io
//Checking the docker version
docker -v

Recreate container and start

docker run -p 3306:3306 --name mysql 

-v /mydata/mysql/log:/var/log/mysql
-v /mydata/mysql/data:/var/lib/mysql
-v /mydata/mysql/conf:/etc/mysql
-e MYSQL_ ROOT_ PASSWORD=root
-d mysql:5.7

[Solved] Logging system failed to initialize using configuration from ‘classpathlogbacklogback-spring.xml‘

2021-12-31:

The project works fine on Windows, but when it is moved to a Mac system, an error appears!

According to the error message, the initialization of “logback-spring.xml” failed, and the configuration of “Logback” was detected as an error and an illegal exception was declared,

Failed to create a parent directory for “[/apps/logs/sns_error.log]”…

The main reason is that the initialization of the configuration file failed, and then the following error was reported.

First, let’s take a look at the input location of the log file defined in the configuration file, as shown below.

The specific error information is as follows:

Logging system failed to initialize using configuration from ‘classpath:logback/logback-spring.xml’
java.lang.IllegalStateException: Logback configuration error detected:
ERROR in ch.qos.logback.core.rolling.RollingFileAppender[ERROR] - Failed to create parent directories for [/apps/logs/sns_error.log]
ERROR in ch.qos.logback.core.rolling.RollingFileAppender[ERROR] - openFile(/apps/logs/sns_error.log,true) call failed. java.io.FileNotFoundException: /apps/logs/sns_error.log (No such file or directory)
ERROR in ch.qos.logback.core.rolling.RollingFileAppender[WARN] - Failed to create parent directories for [/apps/logs/sns_warn.log]
ERROR in ch.qos.logback.core.rolling.RollingFileAppender[WARN] - openFile(/apps/logs/sns_warn.log,true) call failed. java.io.FileNotFoundException: /apps/logs/sns_warn.log (No such file or directory)
ERROR in ch.qos.logback.core.rolling.RollingFileAppender[INFO] - Failed to create parent directories for [/apps/logs/sns_info.log]
ERROR in ch.qos.logback.core.rolling.RollingFileAppender[INFO] - openFile(/apps/logs/sns_info.log,true) call failed. java.io.FileNotFoundException: /apps/logs/sns_info.log (No such file or directory)
ERROR in ch.qos.logback.core.rolling.RollingFileAppender[DEBUG] - Failed to create parent directories for [/apps/logs/sns_debug.log]
ERROR in ch.qos.logback.core.rolling.RollingFileAppender[DEBUG] - openFile(/apps/logs/sns_debug.log,true) call failed. java.io.FileNotFoundException: /apps/logs/sns_debug.log (No such file or directory)
ERROR in ch.qos.logback.core.rolling.RollingFileAppender[TRACE] - Failed to create parent directories for [/apps/logs/sns_trace.log]
ERROR in ch.qos.logback.core.rolling.RollingFileAppender[TRACE] - openFile(/apps/logs/sns_trace.log,true) call failed. java.io.FileNotFoundException: /apps/logs/sns_trace.log (No such file or directory)

Let’s continue with the above

It should be that I don’t know its features very well when I just use Mac, and I don’t know whether it’s caused by different computer environments (I can’t create this directory on MAC)

Follow up: 2021-12-31 PM

Background Note: On Windows my project is in a folder on the D: drive, and today I found the “/apps/logs” directory on the D: drive, just like the path in the configuration below.

When I change the input location of the configuration file to “/apps/logs/sns”, the folder of “SNS” appears on disk D.

As shown in the following figure:

This shows that when the value in this configuration is “relative path”, it will be created in the root directory of the disk where the project is located (for example, if the project is on disk d: then the path is “d:+ relative path”).

Follow up: December 31, 2021

After opening the folder, I found that the following log was created, and then I looked at the error message. It can completely explain the reason for the error: the folder path cannot be created, and then the log file cannot be created, and the log file failed to be opened.

Then reported an error!!

The created log file is shown in the following figure:

The error information is shown in the following figure:

The solution must start with why the file path is not created on the Mac.

There is no concept of disk partition on Mac. Is it because of this reason that you can’t create a path.

Finally, I found the Solution:

On Mac when I remove the backslash at the top of “/apps/logs/sns” and change it to “apps/logs/sns”, it runs successfully

[Solved] Failed to bind properties under ‘spring.datasource.type‘ to java.lang.Class<javax.sql.DataSource>

In the springcloud project, the following error occurs when starting:

***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to bind properties under ‘spring.datasource.type’ to java.lang.Class<javax.sql.DataSource>:
Property: spring.datasource.type
Value: com.zaxxer.hikari.HikariDataSource
Origin: “spring.datasource.type” from property source “bootstrapProperties-config/application/”
Reason: No converter found capable of converting from type [java.lang.String] to type [java.lang.Class<javax.sql.DataSource>]
Action:
Update your application’s configuration
Disconnected from the target VM, address: ‘127.0.0.1:63170’, transport: ‘socket’
Process finished with exit code 1

Solution: Add the following reference to the pom file

        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
        </dependency>

Attach POM file

<?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>
        <artifactId>cloud-plateform-parent</artifactId>
        <groupId>org.shr</groupId>
        <version>1.0.3.RELEASE</version>
    </parent>
    <artifactId>aiservice</artifactId>
    <description>Demo project for Spring Boot</description>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter</artifactId>
        </dependency>
        <!-- http核心 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-all</artifactId>
            <version>1.12.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.protobuf</groupId>
            <artifactId>protobuf-java</artifactId>
            <version>3.17.3</version>
        </dependency>
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid-spring-boot-starter</artifactId>
            <version>1.1.13</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.47</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-consul-all</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.protobuf</groupId>
            <artifactId>protobuf-java-util</artifactId>
            <version>3.17.3</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>5.3.14</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-openfeign-core</artifactId>
            <version>2.2.9.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis-spring</artifactId>
            <version>2.0.6</version>
        </dependency>
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-autoconfigure</artifactId>
            <version>2.2.1</version>
        </dependency>
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis</artifactId>
            <version>3.5.9</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>5.3.14</version>
        </dependency>
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
        </dependency>


    </dependencies>
    <build>
        <finalName>shr-centralized-inspect-service</finalName>
        <!-- os system information plugin, protobuf-maven-plugin needs to get the system information to download the corresponding protobuf program -->
        <extensions>
            <extension>
                <groupId>kr.motd.maven</groupId>
                <artifactId>os-maven-plugin</artifactId>
                <version>1.6.2</version>
            </extension>
        </extensions>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.xolstice.maven.plugins</groupId>
                <artifactId>protobuf-maven-plugin</artifactId>
                <version>0.5.0</version>
                <configuration>
                    <pluginId>grpc-java</pluginId>
                    <protocArtifact>com.google.protobuf:protoc:3.0.2:exe:${os.detected.classifier}</protocArtifact>
                    <pluginArtifact>io.grpc:protoc-gen-grpc-java:1.2.0:exe:${os.detected.classifier}</pluginArtifact>
                    <!-- proto file directory -->
                    <protoSourceRoot>${project.basedir}/src/main/proto</protoSourceRoot>
                    <!-- Generated Java files directory -->
                    <outputDirectory>${project.basedir}/src/main/java/</outputDirectory>
                    <clearOutputDirectory>false</clearOutputDirectory>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>compile-custom</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

How to Solve Spring Boot Maven Build Error

Error 1:

[ERROR]Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.21.0:test (default-test) on project motherBuyBoot: There are test failures.
[ERROR] Please refer to D:\web\motherbuy\target\surefire-reports for the individual test results. [ERROR] Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream.

Solution:

the pom.xml file has the wrong version of Junit, or for some other reason, the junit dependency is commented out and the compilation passes.

 

Error 2:

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project motherBuyBoot: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

Solution:

Method: Compile compile environment problems, that are not configured; see the screenshot below to solve, do not forget to update maven.

[Solved] Failed to start bean ‘documentationPluginsBootstrapper’; nested exception is java.lang.NullPointerException

# org.springframework.context.ApplicationContextException: Failed to start bean ‘documentationPluginsBootstrapper’; nested exception is java.lang.NullPointerException

First, The relevant configurations in my pom.xml are as follows

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.1</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <!--swagger-->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.9.2</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.9.2</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

At this point, my spring-boot-starter version may not match the swagger version, and the following error is reported

org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException

Because Springfox uses path matching based on AntPathMatcher, while Spring Boot 2.6.X uses PathPatternMatcher.

Solution:

Configurate in application.properties:

spring.mvc.pathmatch.matching-strategy=ANT_PATH_MATCHER

The problem can be solved.

[Solved] Python Project Error: django.core.exceptions.ImproperlyConfigured: WSGI application ‘WebTool.wsgi.application

Problem Description: run Python project with pychart and report an error: django.core.exceptions.ImproperlyConfigured: WSGI application ‘WebTool.wsgi.application’ could not be loaded; Error importing module.

See the following for complete error reporting:

D:\Python\project\WebTool>python manage.py runserver 0.0.0.0:8080
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
June 27, 2022 - 09:14:42
Django version 3.2.13, using settings 'WebTool.settings'
Starting development server at http://0.0.0.0:8080/
Quit the server with CTRL-BREAK.
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "C:\Users\admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\servers\basehttp.py", line 45, in get_internal_wsgi_application
    return import_string(app_path)
  File "C:\Users\admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\module_loading.py", line 17, in import_string
    module = import_module(module_path)
  File "C:\Users\admin\AppData\Local\Programs\Python\Python37\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "D:\Python\project\WebTool\WebTool\wsgi.py", line 16, in <module>
    application = get_wsgi_application()
  File "C:\Users\admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\wsgi.py", line 13, in get_wsgi_application
    return WSGIHandler()
  File "C:\Users\admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\handlers\wsgi.py", line 127, in __init__
    self.load_middleware()
  File "C:\Users\admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\handlers\base.py", line 40, in load_middleware
    middleware = import_string(middleware_path)
  File "C:\Users\admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\module_loading.py", line 17, in import_string
    module = import_module(module_path)
  File "C:\Users\admin\AppData\Local\Programs\Python\Python37\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'corsheaders'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\admin\AppData\Local\Programs\Python\Python37\lib\threading.py", line 926, in _bootstrap_inner
    self.run()
  File "C:\Users\admin\AppData\Local\Programs\Python\Python37\lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\commands\runserver.py", line 138, in inner_run
    handler = self.get_handler(*args, **options)
  File "C:\Users\ext.azhang\AppData\Local\Programs\Python\Python37\lib\site-packages\django\contrib\staticfiles\management\commands\runserver.py", line 27, in get_handler
    handler = super().get_handler(*args, **options)
  File "C:\Users\admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\commands\runserver.py", line 65, in get_handler
    return get_internal_wsgi_application()
  File "C:\Users\admin\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\servers\basehttp.py", line 50, in get_internal_wsgi_application
    ) from err
django.core.exceptions.ImproperlyConfigured: WSGI application 'WebTool.wsgi.application' could not be loaded; Error importing module.

Solution: WSGI module needs to be installed

pip install django-cors-headers

Reuse command python manage.py runserver 0.0.0.0:8080 to run the project after installation

After successful operation, see the figure below

[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}

[Solved] SpringCloud Compile Error: java: JPS incremental annotation processing is disabled. Compilation results on partial recompilation may be inaccurate.

Error:

SpringCloud Compile Error: java: JPS incremental annotation processing is disabled. Compilation results on partial recompilation may be inaccurate. Use build process “jps.track.ap.dependencies” VM flag to enable/disable incremental annotation processing environment.

 

Solution:
1.Add: -Djps.track.ap.dependencies=false

2. Clear the caches

[Solved] Vite build & Flask Error: Failed to load module script. Strict MIME type checking is enforced

Vite build & Flask Error: Failed to load module script. Strict MIME type checking is enforced


Stack Overflow

questions

I have this HTML:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link
        rel="stylesheet"
        href="../../../static/css/style.css"
        type="text/css" />
    <link
        rel="stylesheet"
        href="../../../static/css/user_header.css"
        type="text/css" />

    <!--suppress HtmlUnknownTarget -->
    <link rel="shortcut icon" href="/favicon.png">

    <script type="module" src="../../../static/js/node_connect.js" ></script>  <-- Error
    <script src="../../../static/lib/jquery.min.js"></script>
    <script src="../../../static/lib/selfserve.js"></script>   

</head>

The problem is node_connect.jsfile. Start the flash web tool locally (Python 3.7.2), and the console will report the following error when opening the page:

Failed to load module script: The server responded with a non-JavaScript MIME type of "text/plain".
Strict MIME type checking is enforced for module scripts per HTML spec.

Check Title:

Content-Type: text/plain; charset=utf-8

However, in production (when starting through gunicorn), it gives:

Content-Type: application/javascript; charset=utf-8

I guess the web server (APACHE) serves them in the production case, but another thing is that when testing other pages of the web tool, they all work and load JavaScript files correctly (even if their content type is text/plain text). However, the difference is that I notice that in the type.

This applies to my situation:

<script src="../../static/js/translator/library/materialize.js"></script>

Or this:

<script type="application/javascript" src="../../static/js/translator/library/materialize.js"></script>

Of course, I tried this for the problematic JavaScript . File and received the following error (which means it is now loaded):

Uncaught SyntaxError: Cannot use import statement outside a module

According to my research, this basically means that I need to set the type to module (but this will make the browser reject .js files).

Who can help me solve this problem?

best answer:

The problem is caused by flash how to guess the content type of each static file
Import mimetypes from flash and call mimeType, encoding = mimetypes guess_type (download_name) this module creates a database of known MIME types from multiple sources and uses it to return MIME types
Linux and MacOS: look at the mimetypes.py files:

knownfiles = [
    "/etc/mime.types",
    "/etc/httpd/mime.types",                    # Mac OS X
    "/etc/httpd/conf/mime.types",               # Apache
    "/etc/apache/mime.types",                   # Apache 1
    "/etc/apache2/mime.types",                  # Apache 2
    "/usr/local/etc/httpd/conf/mime.types",
    "/usr/local/lib/netscape/mime.types",
    "/usr/local/etc/httpd/conf/mime.types",     # Apache 1.2
    "/usr/local/etc/mime.types",                # Apache 1.3
    ]

But in windows, it will look in the registry:

with _winreg.OpenKey(_winreg.HKEY_CLASSES_ROOT, '') as hkcr:
    for subkeyname in enum_types(hkcr):
        try:
            with _winreg.OpenKey(hkcr, subkeyname) as subkey:
                # Only check file extensions
                if not subkeyname.startswith("."):
                    continue
                # raises OSError if no 'Content Type' value
                mimetype, datatype = _winreg.QueryValueEx(
                    subkey, 'Content Type')
                if datatype != _winreg.REG_SZ:
                    continue
                self.add_type(mimetype, subkeyname, strict)

So to solve the problem, flask thinks JS file is actually a problem of text/plain , just open regedit and adjust this registry key to application/javaScript .

solutions for vite:

Find the registry value, double-click content type to change it to Application/JavaScript , and then restart the computer

if not, please see if your suffix is simple .js, if it is .1242342.js , must be changed to pure .JS suffix can take effect

In order to completely eradicate the disadvantages of modifying files, we can change the configuration file of vite , and modify the name of the output JS file by using the custom packaging option rollupOptions.

Reference: vite2 how to set the file name after packaging

Other configuration items of vite.config.js are shown on the official website. Click here to view more configuration items on the official website.

[Solved] Seata Error: endpoint format should like ip:port

Abnormal scene

Failed to get available servers: endpoint format should like ip:port


Cause of error

Ensure that the versions are consistent. The server version downloaded by Seata must be consistent with the dependent version introduced by Maven

Locally installed version

I use seata1 locally Version 4.0


Maven import version

The imported version is cloud version 2.2.7, which encapsulates Seata

Correspondence between Seata and cloud


How to solve

Just keep the locally installed version of Seata consistent with the version imported by Maven. After I change the imported version of maven, I can introduce Seata version 1.4.0.

 <!-- https://mvnrepository.com/artifact/io.seata/seata-spring-boot-starter -->
 <dependency>
     <groupId>io.seata</groupId>
     <artifactId>seata-spring-boot-starter</artifactId>
     <version>1.4.0</version>
 </dependency>

Of course, you can also go to the official website of Seata to download the corresponding seata1.3 version to Maven.

[Solved] Flask Application Context Error: RuntimeError: Working outside of application context.

[problem description]

The author encountered a classic error in flash. The error information is as follows:

[problem analysis]

application context is the application context of Flask, which contains variables such as app and g. When it is not convenient to operate app, we use current_app instead of app. current_app can only be accessed when processing requests, and I used current_app outside of processing requests, so an error was reported. Specifically, I used current_app in a custom tool class, ran the program, and could not get the application context when the program loaded the tool class, so the error was reported. The error code is as follows.

[problem-solving]

Since you can’t use current_app in the class property in the tool class, comment out the code and put it in the class method, and modify it as follows. The class method defined by me is used in the view, so the current_app is used in the view when processing the request, so no error will be reported and the problem is solved.