Author Archives: Robins

[Solved] ShardingSphere Error: Sharding value must implements Comparable.

Shardingsphere integrates mybatis plus and reports an error. Java.lang.illegalargumentexception: sharding value must implements comparable.

error reason
because shardingsphere’s ID generation strategy is configured in the configuration file, ID is used as the partition key here, and shardingsphere will automatically generate ID value when saving data.

spring.shardingsphere.sharding.tables.user.key-generator.column = id
spring.shardingsphere.sharding.tables.user.key-generator.type = SNOWFLAKE

However, the annotation @tableid is pasted on the entity class, which conflicts with mybatis plus.


@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "`user`")
public class User implements Serializable {
    @TableId(value = "id", type = IdType.INPUT)
    private Long id;

    @TableField(value = "`name`")
    private String name;

    @TableField(value = "address")
    private String address;

    @TableField(value = "birthday")
    private Date birthday;
}

The solution is not to paste @tableid when the primary key is used as the partition key. If you write SQL through an XML file, the primary key column does not need to be written

Python2.7 Pyinstaller Install Error: ERROR: Command errored out with exit status 1

Python2.7 pyinstaller installation error: Command erred out with exit status 1


Error reporting reason:

Installing pyinstaller directly in python2.7 will report an error. Version 4 is incompatible with python2, so we need to specify a compatible pyinstaller version number during installation. The installation commands are as follows:

pip install pyinstaller==3.2.1

Py2exe installation command

pip install py2exe==0.6.9 

Antdesignvue autocomplet completes the problem of repeated error reporting

If the data IDs are different, and there are multiple identical name values or multiple identical Title values, an error will be reported
just do it

    <a-auto-complete
      v-model="ruleForm.companyId"
        placeholder="Please Input"
        optionLabelProp="label"
        @select="onSelect"
        @change="onChangeStore"
      >
        <template slot="dataSource">
          <a-select-option
            v-for="item in dataSource"
            :key="item.id"
            :value="item.id + ''"
            :label="item.name"
          >
            {{ item.name }}
          </a-select-option>
        </template>
    </a-auto-complete>

Error in node when PM2 starts multiple processes in docker

2021-09-13T15:41:15: PM2 log: App [kafka:1] starting in -cluster mode- 2021-09-13T15:41:15: PM2 log: App name:kafka id:2 disconnected 2021-09-13T15:41:15: PM2 log: App [kafka:2] exited with code [0] via signal [SIGINT] 2021-09-13T15:41:15: PM2 log: App [kafka:2] starting in -cluster mode- 2021-09-13T15:41:15: PM2 log: App [kafka:1] online 2021-09-13T15:41:15: PM2 log: App [kafka:2] online /bin/bash:1 ELF ^ SyntaxError: Invalid or unexpected token

Docker start use CMD["pm2-runtime","process.json"].

The configuration file looks like this

{
    "apps" : [
        {
            "name": "kafka",
            "script": "node main.js --NODE_ENV=test",
            "log_date_format"  : "YYYY-MM-DD HH:mm:ss",
            "log_file"   : "/home/logs/log.log",
            "error_file" : "/home/logs/err.log",
            "out_file"   : "/home/logs/out.log",
            "instances": 3,
            "exec_mode": "cluster"
        }
    ]
  }

Start three Kafka instances in docker. But it keeps reporting errors. The reason is “exec_mode” in the configuration file. Delete it. In docker, remember to use process blocking to run in the foreground mode. Do not use the background, otherwise it will start frequently and cause error.

[Solved] Go language gob serialization pointer cannot be addressed Error

1. Error description

An error occurs when using gob serialization: gob: addressable value of type * big. Float

Scenario:

Serializing a data structure contains a map field, where value is the big. Float structure type

type SideBlock {
  ...
  Varphi map[string]big.Float
  ...
}


func (b *SideBlock) Serialization() []byte {
	var res bytes.Buffer
	encoder := gob.NewEncoder(&res)
	err := encoder.Encode(b)
	if err != nil {
		logger.Error("Serialization err : ", err)
	}
	return res.Bytes()
}

Go version: go version go1.16.5 Darwin/arm64

OS: Mac OS BigSur 11.5.2

2. Error reason

The answer is found in issue:

He has a problem using URL. URL as the key of map

The problem lies in the pointer receiver of marshalbinary . If we want to use this structure as a key or value, we need to implement the marshalbinary method for special fields

personal understanding: when a map field of a structure has another structure instead of a pointer to the structure, it is a copy of the structure rather than itself during serialization, so it is difficult to address </ font>

3. Solution

Method 1:

https://play.golang.org/p/dK7SsqahtAd

package main

import (
	"encoding/gob"
	"fmt"
	"io/ioutil"
)

type T struct {
}

func (t *T) String() string { return "" }

func (t T) MarshalBinary() (text []byte, err error) {
	return []byte(t.String()), nil
}

func main() {
	m := make(map[T]int)
	m[T{}] = 0
	e := gob.NewEncoder(ioutil.Discard)
	fmt.Println(e.Encode(m))
}

Method 2:

Change big. Float into a pointer, that is, the field becomes varphi map [string] * big. Float

Network error: SoftWare caused connection abort [How to Solve]

When using mobaxterm software to run a program on the server, there are often “network error: software caused connection abort” errors. The running program will report an error and terminate the program.

Solution:

Open mobaxterm software, find “Settings” in the menu bar, and then click “configuration”
to the box in front of SSH keepalive, ✔ All right.

[Vue error] the solution to the template root requires exactly one element error reporting

Error content
Vue error: the template root requires exactly one element

See the following figure for details:

error information in vscode

error information in node

Error reason
Vue only allows one root node in the template.

Solution

Add a <div> tag to <template>, after that all the components will be added to <div> to solve the problem.

Solutions to error reporting after adding comments to XML files

It took a long time to find the most useful way to feel
set the <?xml version=”1.0″ encoding=”UTF-8″ ?>
change to <?xml version=”1.0″ encoding=”UTF8″ ?>
that is to say, remove –
during the process, I searched a lot of methods on the Internet. If the above methods don’t work, I can try the following two methods:
1. Add configuration in pom.xml file

<properties>
       <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

2. Change the idea configuration

note: it is only during the process of finding that the XML annotation format is

<!-- Contents --> Right
<! --content --> wrong
To be separated by two spaces, but I do not think it has much impact, after changing the format still does not support comments

springboot sqlserver druid reward: validateConnection false

The exception information is as follows:

java.sql.SQLException: validateConnection false
	at com.alibaba.druid.pool.DruidAbstractDataSource.validateConnection(DruidAbstractDataSource.java:1418)
	at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1733)
	at com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(DruidDataSource.java:2801)
Caused by: java.lang.NullPointerException: null
	at com.alibaba.druid.wall.WallProvider.checkInternal(WallProvider.java:707)
	at com.alibaba.druid.wall.WallProvider.check(WallProvider.java:584)
	at com.alibaba.druid.wall.WallFilter.checkInternal(WallFilter.java:826)
	at com.alibaba.druid.wall.WallFilter.check(WallFilter.java:821)
	at com.alibaba.druid.wall.WallFilter.statement_execute(WallFilter.java:454)
	at com.alibaba.druid.filter.FilterChainImpl.statement_execute(FilterChainImpl.java:3008)
	at com.alibaba.druid.filter.FilterAdapter.statement_execute(FilterAdapter.java:2484)
	at com.alibaba.druid.filter.FilterEventAdapter.statement_execute(FilterEventAdapter.java:188)
	at com.alibaba.druid.filter.FilterChainImpl.statement_execute(FilterChainImpl.java:3008)
	at com.alibaba.druid.proxy.jdbc.StatementProxyImpl.execute(StatementProxyImpl.java:147)
	at com.alibaba.druid.pool.vendor.MSSQLValidConnectionChecker.isValidConnection(MSSQLValidConnectionChecker.java:50)
	at com.alibaba.druid.pool.DruidAbstractDataSource.validateConnection(DruidAbstractDataSource.java:1398)

Follow this method: com.alibaba.druid.pool.druidabstractdatasource.validateconnection

result = validConnectionChecker.isValidConnection(conn, validationQuery, validationQueryTimeout);

Find the exception of this line of code and enter this method

Find the method of this implementation class (because it is SQL server)

public boolean isValidConnection(final Connection c, String validateQuery, int validationQueryTimeout) throws Exception {
        if (c.isClosed()) {
            return false;
        }

        Statement stmt = null;

        try {
            stmt = c.createStatement();
            if (validationQueryTimeout > 0) {
                stmt.setQueryTimeout(validationQueryTimeout);
            }
            stmt.execute(validateQuery);
            return true;
        } catch (SQLException e) {
            throw e;
        } finally {
            JdbcUtils.close(stmt);
        }
    }

Finally, it is found that the method parameter validatequery is null, so a null pointer is reported. Let’s go back and see why it is null

protected volatile String                          validationQuery                           = DEFAULT_VALIDATION_QUERY;

Class defines that validationquery is equal to default_ VALIDATION_ Query, and default_ VALIDATION_ Query initialization is defined as null. In fact, this parameter comes from the springboot configuration file

Add the following configuration in the springboot data source configuration file:

druid:
                        validation-query: SELECT 1

Just do it!

PS, data source configuration:

driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
url: jdbc:sqlserver://IP:PORT;DatabaseName=database name
username: username
password: password
druid:
    validation-query: SELECT 1

Android uses the Android iconics font library error [How to Solve]

Today, after using the font library on GitHub, it is found that the control has not been recognized after the successful introduction:

Android-Iconics

introduce:

//Font library
implementation 'com.mikepenz:iconics-core:5.3.0@aar'
//this adds all ui view widgets (IconicsButton, IconicsImageView, ...)
implementation 'com.mikepenz:iconics-views:5.3.0'

After trying several ways, I found that the problem is that the kotlin version of Android studio is too low

My original plug-in version is 1.3.6. After updating to 1.4.10, I successfully referenced it