How to Solve Springmvc Error: org.springframework.web.servlet.DispatcherServlet

When writing springMVC, after importing all required packages, run the program, the console reports the following error:

Critical: Servlet [springDispatcherServlet] in web application [/SpringMVC-1 ] threw load() exception
java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java: 1333 )
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java: 1167 )
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java: 518 )
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java: 499 )
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java: 118 )
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java: 1091 )
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java: 1027 )
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java: 5038 )
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java: 5348 )
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java: 145 )
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java: 725 )
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java: 701 )
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java: 717 )
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java: 587 )
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java: 1798 )
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

You can’t import org.springframework.web.servlet.DispatcherServlet in a java file. This class is mainly under the spring-webmvc jar package. All imported jar packages are as follows:

All have been imported, there is no problem. But in fact, all dependencies must be added to the classpath. step:

Right-click the project–>properties–>Deployment Assembly–>add–>Java Build Path Entries–>import all dependent Jar packages and restart tomcat.

Mysql5.7.18.1 Error 1054 (42S22): Unknown Column’password’ In’field List’ When Changing User Password

This intention is to modify a user’s password, the command found on the Internet is as follows

mysql> update user set password=password(“new password”) where user=”username”;

ERROR 1054(42S22) Unknown column’password’ in’field list’ is reported after execution

The reason for the error is that there is no password field in the mysql database under version 5.7, and the password field is changed to authentication_string

So please use the following command:

>mysql -u root -p
Enter password: ********
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.7.18-log MySQL Community Server (GPL)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use mysql;
Database changed
mysql > select User from user; #here is the query user command
 +-----------+
| User      |
+-----------+
| ******* |
| mysql.sys |
| root      |
+-----------+
3 rows in set (0.00 sec)

mysql > update user set password=password( " ******* " ) where user = " ******* " ; #Modify password error
ERROR 1054 (42S22): Unknown column 'password' in 'field list'
mysql> update mysql.user set authentication_string=password('*******') where user='*******';  #修改密码成功
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 1

mysql > flush privileges; #effective immediately
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye

n >mysql -u *******- p #Log in as this user successfully.
Enter password: ********
…………………………
mysql>

SQL Developer error: Unable to find a Java Virtual Machine solution

I installed a 64-bit Oracle database and a 32-bit Oracle client. When I opened the client’s SQL Developer in the start menu for the first time, I was prompted to enter the path of java.exe. I chose the jdk path that comes with the Oracle database. After confirming, an error was reported. :

Baidu looked for a solution. The reason is that the built-in jdk in the 64-bit Oracle database is also 64-bit, but the installed Oracle client is 32-bit, so it is not compatible.

There are two general solutions:

1) Download Oracle SQL Developer x64 from the Internet ( http://www.oracle.com/technetwork/developer-tools/sql-developer/downloads/index.html ), and then replace the original directory: D:\app\oracle\product 32-bit Oracle SQL Developer under \11.1.0\db_1\sqldeveloper. Restart Oracle SQL Developer and specify the path of java.exe.
2) Install JDK6 x86, which is 32-bit JDK. Although our system is 64-bit, it is also compatible with 32-bit JDK.

Due to other needs, I must use a 32-bit client, so I chose the second method. I downloaded the 32-bit jdk from the Oracle official website and installed it. After that, modify the java.exe startup path of SQL Developer. At this time, you cannot click SQL Developer in the start menu to define the java.exe path, because the path has already been initialized, and the above error will be reported when you click SQL Developer. At this time, if you want to modify the java.exe path, you need to modify the configuration file.

1. Find the sqldeveloper.conf file in the following path

D:\app\mattran\product\11.2.0\client_1\sqldeveloper\sqldeveloper\bin

2. Open the file

3. Change the path at the red line to the path of the 32-bit jdk just installed as follows:

4. Save and exit.

 Then click SQL Developer under Oracle-OraClient11g_home1 in the start menu to start successfully.

Hadoop Error: hdfs.DFSClient: Exception in createBlockOutputStream

java.io.EOFException: Premature EOF: no length prefix available
at org.apache.hadoop.hdfs.protocolPB.PBHelper.vintPrefixed(PBHelper.java:1492)
at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.createBlockOutputStream(DFSOutputStream.java:1155)
at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.nextBlockOutputStream(DFSOutputStream.java:1088)
at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.run(DFSOutputStream.java:514)
15/03/24 18:26:40 INFO hdfs.DFSClient: Abandoning BP-1909118226-192.168.19.234-1427110524238:blk_1073762363_21550
15/03/24 18:26:40 INFO hdfs.DFSClient: Excluding datanode 192.168.21.24:50010
copy from: /root/zenggq/jn2/data2w/t0.head_2000 to /recom1000/t0.head_2000
15/03/24 18:26:41 INFO hdfs.DFSClient: Exception in createBlockOutputStream
java.io.EOFException: Premature EOF: no length prefix available
at org.apache.hadoop.hdfs.protocolPB.PBHelper.vintPrefixed(PBHelper.java:1492)
at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.createBlockOutputStream(DFSOutputStream.java:1155)
at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.nextBlockOutputStream(DFSOutputStream.java:1088)
at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.run(DFSOutputStream.java:514)
15/03/24 18:26:41 INFO hdfs.DFSClient: Abandoning BP-1909118226-192.168.19.234-1427110524238:blk_1073762365_21552
15/03/24 18:26:41 INFO hdfs.DFSClient: Excluding datanode 192.168.21.23:50010
15/03/24 18:26:41 INFO hdfs.DFSClient: Exception in createBlockOutputStream
java.io.IOException: Bad connect ack with firstBadLink as 192.168.21.24:50010
at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.createBlockOutputStream(DFSOutputStream.java:1166)
at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.nextBlockOutputStream(DFSOutputStream.java:1088)
at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.run(DFSOutputStream.java:514)
15/03/24 18:26:41 INFO hdfs.DFSClient: Abandoning BP-1909118226-192.168.19.234-1427110524238:blk_1073762366_21553
15/03/24 18:26:41 INFO hdfs.DFSClient: Excluding datanode 192.168.21.24:50010
15/03/24 18:26:41 INFO hdfs.DFSClient: Exception in createBlockOutputStream
java.io.EOFException: Premature EOF: no length prefix available
at org.apache.hadoop.hdfs.protocolPB.PBHelper.vintPrefixed(PBHelper.java:1492)
at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.createBlockOutputStream(DFSOutputStream.java:1155)
at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.nextBlockOutputStream(DFSOutputStream.java:1088)
at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.run(DFSOutputStream.java:514)
15/03/24 18:26:41 INFO hdfs.DFSClient: Abandoning BP-1909118226-192.168.19.234-1427110524238:blk_1073762367_21554
15/03/24 18:26:41 INFO hdfs.DFSClient: Excluding datanode 192.168.19.236:50010
15/03/24 18:26:41 INFO hdfs.DFSClient: Exception in createBlockOutputStream
java.io.EOFException: Premature EOF: no length prefix available
at org.apache.hadoop.hdfs.protocolPB.PBHelper.vintPrefixed(PBHelper.java:1492)
at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.createBlockOutputStream(DFSOutputStream.java:1155)
at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.nextBlockOutputStream(DFSOutputStream.java:1088)
at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.run(DFSOutputStream.java:514)
15/03/24 18:26:41 INFO hdfs.DFSClient: Abandoning BP-1909118226-192.168.19.234-1427110524238:blk_1073762368_21555
15/03/24 18:26:41 INFO hdfs.DFSClient: Excluding datanode 192.168.21.30:50010
15/03/24 18:26:41 WARN hdfs.DFSClient: DataStreamer Exception
java.io.IOException: Unable to create new block.
at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.nextBlockOutputStream(DFSOutputStream.java:1100)
at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.run(DFSOutputStream.java:514)
15/03/24 18:26:41 WARN hdfs.DFSClient: Could not get block locations. Source file “/recom1000/t1.head_2000” – Aborting…
Exception in thread “main” java.io.EOFException: Premature EOF: no length prefix available
at org.apache.hadoop.hdfs.protocolPB.PBHelper.vintPrefixed(PBHelper.java:1492)
at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.createBlockOutputStream(DFSOutputStream.java:1155)
at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.nextBlockOutputStream(DFSOutputStream.java:1088)
at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.run(DFSOutputStream.java:514)
15/03/24 18:26:41 ERROR hdfs.DFSClient: Failed to close file /recom1000/t1.head_2000
java.io.EOFException: Premature EOF: no length prefix available
at org.apache.hadoop.hdfs.protocolPB.PBHelper.vintPrefixed(PBHelper.java:1492)
at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.createBlockOutputStream(DFSOutputStream.java:1155)
at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.nextBlockOutputStream(DFSOutputStream.java:1088)
at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.run(DFSOutputStream.java:514)
[root@master jn2]#

I found the answer in a circle. One said that the datanode process did not exist, but that the firewall was not turned off. It turned out that I had no problem with both.

Later, I deleted the data directory under hadoop-dir. Then reformat the namenode

hadoop purpose -format

And then it’s ready

Spring deployment error: Could not open ServletContext resource [/db.properties]

In the process of using Spring MVC, the deployment project reports an error, and the error message is as follows:

Agu 15, 2016 5:02:04 PM org.apache.catalina.core.StandardContext listenerStart
warning: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/db.properties]
at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.postProcessBeanFactory(PropertySourcesPlaceholderConfigurer.java:151)
…….
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/db.properties]
at org.springframework.web.context.support.ServletContextResource.getInputStream(ServletContextResource.java:141)
at org.springframework.core.io.support.EncodedResource.getInputStream(EncodedResource.java:153)
… 51 more

………………………………………….. ………………………………………….. ………………………………………….. …………………….

For the Maven project, the application-context.xml and db.properties files are all placed in the src/main/resources directory. For the Tomcat deployment project, the default location of the configuration file in the src/main/resources directory is: {project name}/WEB-INF /classes, but Spring looks for it in the root directory of the project, and it is definitely not found. Therefore, you can find it in the classpath directory when configuring it.

The solution is as follows:

<context:property-placeholder location=”classpath:db.properties” />

Tomcat startup error: Failed to start component [StandardServer[8005]] solution

SEVERE: The required Server component failed to start so Tomcat is unable to start. org.apache.catalina.LifecycleException: Failed to start component [StandardServer[8005]]

The Tomcat server was deployed on Eclipse before, and it was deployed on MyEclipse today. As a result, Tomcat failed to start and an error was reported. After searching the Internet for a long time, some said it was because the port was occupied, and some said it was because of the wrong version of Tomcat’s JDK. Actually neither. The reason is that the last few extra lines in Tomcat’s server.xml configuration file are probably automatically generated by projects that were previously run on Eclipse. After deleting them, Tomcat will run normally.

 

 <Host appBase=”webapps” autoDeploy=”true” name=”localhost” unpackWARs=”true”>

<Valve className=”org.apache.catalina.authenticator.SingleSignOn” />

<Valve className=”org.apache.catalina.valves.AccessLogValve” directory=”logs” pattern=”%h %l %u %t “%r” %s %b” prefix=”localhost_access_log.” suffix=” .txt”/> 

<Context docBase=”MyProject” path=”/MyProject” reloadable=”true” source=”org.eclipse.jst.jee.server:MyProject”/></Host>

Java.lang.AbstractMethodError: org.mybatis.spring.transaction.SpringManagedTransaction.getTimeout()Ljava/lang/Integer; error resolution

In mybatis+spring integration, an error will be reported due to version issues:

java.lang.AbstractMethodError: org.mybatis.spring.transaction.SpringManagedTransaction.getTimeout()Ljava/lang/Integer;
at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:85)
at org.apache.ibatis .executor.SimpleExecutor.doQuery(SimpleExecutor.java:62)
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:325)
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156 )
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:83)
at org.apache.ibatis.session.defaults. DefaultSqlSession.selectList(DefaultSqlSession.java:148)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect. DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:408)
at com.sun.proxy.$Proxy12. selectList(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:206)
at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:128)
at org.apache.ibatis.binding. MapperMethod.execute(MapperMethod.java:68)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:53)
at com.sun.proxy.$Proxy13.selectByExample(Unknown Source)
at bz.beppe.daoTest.SeckillMapperTest.selectByExample(SeckillMapperTest.java:26 )
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source )
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model .FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:73)
at org.springframework.test .context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:73)
at org.junit.runners.ParentRunner.runLeaf (ParentRunner.java:271)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:224)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:83)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java :236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.springframework.test.context.junit4. statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:68)
at org.junit.runners.ParentRunner.run(ParentRunner.java: 309)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:163)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt .internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit .runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner .main(RemoteTestRunner.java:192)

 For the root cause of this problem, you can check the official website of mybatis for the application of mybatis-spring jar package version

MyBatis-Spring MyBatis Spring
1.0.0 and 1.0.1 3.0.1 to 3.0.5 3.0.0 or higher
1.0.2 3.0.6 3.0.0 or higher
1.1.0 or higher 3.1.0 or higher 3.0.0 or higher
1.3.0 or higher 3.4.0 or higher 3.0.0 or higher

Use this correspondence to select the version of the mybatis-spring jar package you need

I used spring 4.1+mybatis 3.4 and mybatis-spring used version 1.2, which caused the project to report an error. After I changed it to version 1.3.0, everything was normal! !

Solve the data transfer between vue irrelevant components error: this.$store.commit is not a function

In a Vue project, if the project is simple, the data transfer between parent and child components can be passed using props or $emit etc.

But if it is a large and medium-sized project, it is often necessary to transfer data between unrelated parallel components, and many data require multiple components to be recycled. At this time, using the above method will make the project code verbose, and is not conducive to the reuse of components, which improves the degree of coupling.

Vue’s state management tool Vuex perfectly solves this problem.

I looked at the official website of vuex, and I don’t think it is very easy to understand. Sometimes we just need to dynamically get data from a component (the official website is called “component level”: it is an independent control, and the scope of action is only within the component) and then I want to put it in a place called “application level” by the official website (it can be accessed and dynamically modified anywhere in the project. After the modification, vue will update your entire project). This is the reason why I first came to learn vue. I didn’t want to make a front-end data structure library. . .

Let’s take a look at my small example step by step

First install vuex. The company project has been migrated from vue1.0 to vue2.0 by me, download and install vue  

npm install vuex –save

Then create a new folder store at the same level as index.html, and create a new index.js file in the folder. This file is used to assemble the module and export the store file

 

[1. Get the data in the store]

import Vue from  ' vue ' 
import Vuex from  ' vuex '

// Tell vue to "use" vuex 
Vue.use(Vuex)

// Create an object to save the initial state when the application starts
 // The state that needs to be maintained 
const store = new Vuex.Store({
  state: {
    // Place the initial global initial value when the app is started 
    bankInf: { " name " : " I am the first data of vuex " , " id " : 100 , " bankName " : " Bank of China " }
  }
})
// Integrate the initial state and change function, we get the store we need
 //So far, this store can be connected to our application 
export default store

Register the store in the vue root file so that all components can use the data in the store

My project file structure:

 

Register store in the main.js file

import Vue from  ' vue ' 
import App from  ' ./App ' 
import router from  ' ./router ' 
import store from  ' ./../store/index '

/* eslint-disable no-new */ 
new Vue({
  el: ' #app ' ,
  router,
  store,
  template: ' <App/> ' ,
  components: {App}
})

This simple first step is complete. You can use the data in the store in any component. The method of use is also very simple, that is, use the calculated attribute to return the data in the store to a new attribute, and then you can use it in your template. Use this attribute value:

In any component:

export default {
  ...
  computed: {
    bankName() {
      return  this .$store.state.bankInf.bankName;
    }
  },
  ...
}

The bankName attribute can be used directly in the template, which is the Bank of China in the store

 

[Two, modify the state in the store in the component]

Add html template to any component

<div class = " bank " >
    <list-header :headerData= " bankName " ></list-header>
    04Bank Details Page
    <input name= "" v-model= " textValue " >
    <button type= " button " name= " Get data " @click= " newBankName " ></button>
</div>

Then submit the mutation in the component

export default {
  ...
  computed: {
    bankName() {
      return  this .$store.state.bankInf.bankName;
    }
  },
  methods: {
    newBankName: function() {
      this .$store.commit( ' newBankName ' , this .textValue)
    }
  }
 ...   
}

Add mutations to index.js in the store:

const store = new Vuex.Store({
  state: {
    // Place the initial global initial value when the app is started 
    bankInf: { " name " : " I am the first data of vuex " , " id " : 100 , " bankName " : " Bank of China " },
    count: 0
  },
  mutations: {
    newBankName(state,msg) {
      state.bankInf.bankName = msg;
    }
  }
})

In this way, you find that when you click the submit button, the page has displayed the data you modified, and all the data in the place where this component is reused has been updated by Vue;

 

If you find an error this.$store.commit is not a function during use, please open the configuration file package.json of your project and check the version of vuex you are using. I am using vuex2.0,

If you want to delete the old version of vuex and install the new version of vuex, please use

npm rm vuex –save

Then install the latest vuex

npm install vuex –save

You can solve this error, or check the vuex official website api to modify the statement submitted to the mutation

How to Solve Error: You need to use a Theme.AppCompat theme (or descendant) with this activity.

When learning the activity life cycle, I hope to test the difference between onPause() and onStop() through the Dialog theme. When clicking the button to jump to the Activity, an error is reported:

E/AndroidRuntime: FATAL EXCEPTION: main
                  Process: com.example.activitylifecycletest, PID: 2920
                  java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.activitylifecycletest/com.example.activitylifecycletest.DialogActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
                      at android.app.ActivityThread.-wrap12(ActivityThread.java)
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
                      at android.os.Handler.dispatchMessage (Handler.java:102)
                      at android.os.Looper.loop(Looper.java:154)
                      at android.app.ActivityThread.main(ActivityThread.java:6077)
                      at java.lang.reflect.Method.invoke(Native Method)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
                   Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
                      at android.support.v7.app.AppCompatDelegateImplV9.createSubDecor(AppCompatDelegateImplV9.java:347)
                      at android.support.v7.app.AppCompatDelegateImplV9.ensureSubDecor(AppCompatDelegateImplV9.java:316)
                      at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:281)
                      at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
                      at com.example.activitylifecycletest.DialogActivity.onCreate(DialogActivity.java:11)
                      at android.app.Activity.performCreate(Activity.java:6664)
                      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707) 
                      at android.app.ActivityThread.-wrap12(ActivityThread.java) 
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460) 
                      at android.os.Handler.dispatchMessage (Handler.java:102) 
                      at android.os.Looper.loop(Looper.java:154) 
                      at android.app.ActivityThread.main(ActivityThread.java:6077) 
                      at java.lang.reflect.Method.invoke(Native Method) 
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) 
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

Find the most useful sentence, indicating that the theme used does not match the current Activity:

You need to use a Theme.AppCompat theme (or descendant) with this activity.

The activity configuration in AndroidManifest.xml is as follows:

1 <activity
2     android:name=".DialogActivity"
3     android:theme="@android:style/Theme.Dialog">
4 </activity>

Change the theme to AppCompat according to the error message:

1 <activity
2     android:name=".DialogActivity"
3     android:theme="@style/Theme.AppCompat.Dialog">
4 </activity>

After checking the java code, I found that my Activity inherits the AppCompatActivity class. When creating an Activity in Android Studio, if you check the Backwards Compatibility (AppCompat) option, the created Activity will inherit AppCompatActivity instead of Activity, and you need to use the corresponding AppCompat theme.

java code:

 1 import android.support.v7.app.AppCompatActivity;
 2 import android.os.Bundle;
 3 
 4 public class DialogActivity extends AppCompatActivity {
 5 
 6     @Override
 7     protected void onCreate(Bundle savedInstanceState) {
 8         super.onCreate(savedInstanceState);
 9         setContentView(R.layout.activity_dialog);
10     }
11 
12 }

Solution for Python3.7 import gevent module error

Recently updated python interpreter 3.7

As a result, gevent was installed, and an error was reported after gevent was imported. The error message is as follows

RuntimeWarning: greenlet.greenlet size changed, may indicate binary incompatibility. Expected 144, got 128
  return f(*args, **kwds)

Seeing that there are not many posts about this issue, I posted it first.

Just execute the following piece of code.

pip3 install -U --force-reinstall --no-binary :all: gevent

Attach parameter description

-U, --upgrade
Upgrade all specified packages to the newest available version. The handling of dependencies depends on the upgrade-strategy used.
--force-reinstall
Reinstall all packages even if they are already up-to-date.
--no-binary <format_control>
Do not use binary packages. Can be supplied multiple times, and each time adds to the existing value. Accepts either :all: to disable all binary packages, :none: to empty the set, or one or more package names with commas between them. Note that some packages are tricky to compile and may fail to install when this option is used on them.

The general meaning of this command is to use a non-binary package to reinstall gevent and its dependencies.

In short, the problem was solved perfectly after executing this command.

The currently installed gevent version and greenlet version are 1.3.5 and 0.4.14 respectively

Vue Import Baidu map error: BMap is not defined, eslint BMap reports an error

When the mounted map is initialized, BMap is not defined due to asynchronous issues, that is, the map has been initialized before Baidu’s api is fully introduced or loaded.

Solution:

1. Create a map.js

export function MP(ak) {
   return  new Promise( function (resolve, reject) {
    window.init = function () {
      resolve(BMap)
    }
    var script = document.createElement('script' )
    script.type ='text/javascript' 
    script.src = `http: // api.map.baidu.com/api?v=2.0&ak=${ak}&callback=init` 
    script.onerror = reject
    document.head.appendChild(script)
  })
}

2. Reference in the .vue file 

import {MP} from'../map.js'

3. Initialize in the mounted function

   this .$nextTick(() => {
      const _this = this 
      MP(_this.ak).then(BMap => {
        _this.initMap()
      })
    })

Undefined BMap in map.js will report an error

 

 Solution:

Make a global declaration in eslintrc.js

  globals: {
    BMap: true 
  }

 

 That’s it~~

How to Solve Error: Missing type map configuration or unsupported mapping

Error: Missing type map configuration or unsupported mapping

□ Background

When saving the View Model into Domain Model, an error occurred in AutoMapper.

 

□ Analysis

1. A mapping has been established in the Profile class derived from AutoMapper:
Mapper.CreateMap<SomeDomainModel, SomeViewModel>();

 

2. The classes derived from Profile have also been initialized:

    public  static  class AutoMapperConfiguration
    {
        public  static  void Configure()
        {
            Mapper.Initialize(x => x.AddProfile<SomeProfile>());
 
        }
    }

3. Also registered in the global:

        protected  void Application_Start()
        {
            //Configuration mapping
            AutoMapperConfiguration.Configure();
        }

4. The unit test also passed:

    [TestClass]
    public  class AutoMapperConfigurationTester
    {
        [TestMethod]
        public  void TestMethod1()
        {
            AutoMapperConfiguration.Configure();
            Mapper.AssertConfigurationIsValid();
        }
    }

□ Solution

When actually mapping, replace AutoMapper.Mapper.Map<Source, Destination> with AutoMapper.Mapper.DynamicMap<Source, Destination>

DomainModel someDomainModel = AutoMapper.Mapper.Map<ViewModel, DomainModel>(someViewModel);

Change to:

DomainModel someDomainModel = AutoMapper.Mapper.DynamicMap<ViewModel, DomainModel>(someViewModel);