Tag Archives: java

[Solved] BeanCreationNotAllowedException Error: Error creating bean with name ‘rabbitConnectionFactory‘

org.springframework.beans.factory.BeanCreationNotAllowedException:

Error creating bean with name ‘rabbitConnectionFactory’:

Singleton bean creation not allowed while singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)

Once the project reports this error, in most cases, the sub paths in the control layer are repeated, and non unique channels appear during compilation, as shown below

After copying, the sub path of the control layer access path has been changed accordingly

[Solved] ssm Error: Error creating bean with name ‘employeeController’: Injection of autowired dependencies failed

08-Dec-2021 12:08:06.572 Warning [RMI TCP Connection(3)-127.0.0.1] org.springframework.web.servlet.DispatcherServlet.initServletBean Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘employeeController’: Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.lyq.ssm.service.EmployeeService com.lyq.ssm.controller.EmployeeController.employeeService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘employeeService’: Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.lyq.ssm.dao.EmployeeMapper com.lyq.ssm.service.EmployeeService.employeeMapper; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.lyq.ssm.dao.EmployeeMapper] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:292)

1.Scanning whether the annotation is open
Opened

<context:component-scan base-package="com.lyq.ssm">
        <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"></context:exclude-filter>
</context:component-scan>

2. Whether spring listener is configured
if it is not configured:

    <!--Configure spring's listener to load only the files in the WEB-INFO directory by default-->
<listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

After the configuration is completed, it runs successfully

springboot Integrate mybatis Error: Error creating bean with name ‘deptController‘: Unsatisfied dependency expresse


Error creating bean with name ‘deptController’: Unsatisfied dependency expressed through field ‘departmentMapper’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘departmentMapper’ defined in file [D:\demo16\target\classes\com\example\demo\mapper\DepartmentMapper.class]: Unsatisfied dependency expressed through bean property ‘sqlSessionFactory’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sqlSessionFactory’ defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method ‘sqlSessionFactory’ threw exception; nested exception is java.io.FileNotFoundException: class path resource [mybatis/mybaties-config.xml] cannot be opened because it does not exist

Error situation analysis.
1. mapping xml file in the namespace and resultType full class name attention to the correct reference.
2. yml file mybatis config and mapper address note that the best direct reference, not hand-typed.

[Solved] org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘xxx‘

1. Problem description

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.config.internalAutoProxyCreator': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/aspectj/lang/annotation/Around

2. Anomaly analysis

org. springframework. beans. factory. BeanCreationException: Error creating bean with name ‘XXX’

This exception is: bean injection failure exception. If this exception occurs, the corresponding bean cannot be found! The reasons for bean injection failure include but are not limited to the following:

The corresponding bean is not annotated; There is an error adding annotation to the corresponding bean, for example, the @service of spring is incorrectly selected as Dubbo; Select the wrong automatic injection method, etc.

Caused by: java.lang.ClassNotFoundException: org.aspectj.lang.annotation. Around

Missing aspect, Maven coordinate of AOP

   <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <version>4.3.12.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aspects</artifactId>
            <version>4.3.12.RELEASE</version>
        </dependency>

After adding dependency, the problem is solved

[Solved] Artifact spbjh:war exploded: Error during artifact deployment. See server log for details.

Resolve artifact spbjh: War expanded: error during artifact deployment See server log for details.

Sometimes, if the project cannot be started, the following error will be reported

1 First, let’s delete this place

2. Delete this

replace this with the configuration in its corresponding directory

sometimes the jar package conflicts, which will also lead to startup failure

Add

again to start.

Error querying database. Cause: java.sql.SQLSyntaxErrorException: Expression #2 of SELECT list is no

Error reporting for startup project:
error querying database Cause: java. sql. Sqlsyntaxerrorexception: expression #2 of select list is no…
solution:
Enter MySQL with CMD root account
execute commands in MySQL

SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));

Or use other connection tools to connect (root permission is required);

[Solved] Zookeeper cluster error: Error contacting service It is probably not running. (alicloud server)

1. Error code

java.net.ConnectException: Connection refused (Connection refused)
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:476)
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:218)
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:200)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:394)
	at java.net.Socket.connect(Socket.java:606)
	at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:648)
	at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:705)
	at org.apache.zookeeper.server.quorum.QuorumCnxManager.toSend(QuorumCnxManager.java:618)
	at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.process(FastLeaderElection.java:477)
	at org.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.run(FastLeaderElection.java:456)
	at java.lang.Thread.run(Thread.java:748)

2. The cluster is not connected

# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial 
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
dataDir=/usr/local/zookeeper2/zk1/data
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the 
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
server.0=ip:2888:3888
server.1=ip:2889:3889
server.2=ip:2890:3890

3. Solution

Put zoo Replace the IP in CFG with the IP found by ifconfig

Compared with many posts on the Internet, I couldn’t find a solution. Finally, I found that it was zoo The IP in CFG is wrong (I use the IP given by alicloud server, but here I need to use ifconfig to find out the IP. The two are different.

Command failed with error 16412: ‘FieldPath field names may not contain ‘.‘.‘ on server 10.21.20.8:2

    problem description
    query interface error:

    {"errorMessage":
    "Command failed with error 16412: 'FieldPath field names may not contain '.'.' on server 10.21.20.8:27019. The full response is { \"ok\" : 0.0, \"errmsg\" : \"FieldPath field names may not contain '.'.\", \"code\" : 16412, \"codeName\" : \"Location16412\" }"}
    
    
    com.mongodb.MongoCommandException: Command failed with error 16412: 'FieldPath field names may not contain '.'.' on server 10.21.20.8:27019. The full response is { "ok" : 0.0, "errmsg" : "FieldPath field names may not contain '.'.", "code" : 16412, "codeName" : "Location16412" }
        at com.mongodb.connection.ProtocolHelper.getCommandFailureException(ProtocolHelper.java:115)
        at com.mongodb.connection.CommandProtocol.execute(CommandProtocol.java:114)
        at com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:168)
        at com.mongodb.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:289)
        at com.mongodb.connection.DefaultServerConnection.command(DefaultServerConnection.java:176)
        at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:216)
        at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:207)
        at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:113)
        at com.mongodb.operation.AggregateOperation$1.call(AggregateOperation.java:257)
        at com.mongodb.operation.AggregateOperation$1.call(AggregateOperation.java:253)
        at com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:435)
        at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:408)
        at com.mongodb.operation.AggregateOperation.execute(AggregateOperation.java:253)
        at com.mongodb.operation.AggregateOperation.execute(AggregateOperation.java:67)
        at com.mongodb.Mongo.execute(Mongo.java:836)
        at com.mongodb.Mongo$2.execute(Mongo.java:823)
        at com.mongodb.DBCollection.aggregate(DBCollection.java:1455)
        at com.mongodb.DBCollection.aggregate(DBCollection.java:1418)
        at com.mongodb.DBCollection.aggregate(DBCollection.java:1403)
        at com.linkus.biz.prj.service.impl.PrjDevTaskStatServiceImpl.getPrjDevTaskStatData(PrjDevTaskStatServiceImpl.java:127)
    
    
      problem solving
      check the fields in the group. The grouping fields are wrong. The value “joinbiz. Resp” of resp in the group is changed to “resp”

      "$group":{
      	"_id":{
      		"prjSys":"$prjSys",
      		"prjMod":"$prjMod",
      		"resp":"$_joinBiz_.resp",
      	},
      	"devTasksCount":{
      		"$sum":1
      	},
      	"minPlanEndDate":{
      		"$min":"$_joinBiz_.planEndDate"
      	},
      	"maxPlanEndData":{
      		"$max":"$_joinBiz_.planEndDate"
      	},
      	"planCompletionCount":{
      		"$sum":"$planCompletionNum"
      	},
      	"actualCompletionCount":{
      		"$sum":"$actualCompletionNum"
      	}      
      }
      

Idea create Maven project Error: [error] no longer supports source option 1.5. Please use version 1.6 or higher, and the idea reports an error: error: Java does not support the error of release version 5

Project scenario:

As soon as the Maven project changes the POM file, the language level automatically becomes 5

Problem Description:

question 1: the Tomcat plug-in under move starts with an error
[error] the source option 1.5 is no longer supported. Please use version 1.6 or later
[error] target option 1.5 is no longer supported. Please use version 1.6 or later
idea error: error: Java does not support release version 5. This error


Cause analysis:

Maven is a project management tool. If you don’t tell it what JDK version to use for code compilation, it will be handled with the default JDK version of the compilation plug-in Maven compi ler plugin, which is prone to version mismatch, which may lead to failure of compilation


Solution:

to avoid this situation, the first step when building a maven project is to configure the Maven compiler plugin in the project POM XML file specifies the JDK version of the project source code, the compiled JDK version, and the encoding method

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.5.1</version>
        <configuration>
          <source>9</source>
          <target>9</target>
          <encoding>utf-8</encoding>
        </configuration>
      </plugin>


Error running ‘Application‘: Command line is too long [How to Solve]

Unable to run the main program, the command line is too long.

How to solve it?First find the workspace in the project XML file,

Then find <component name=”PropertiesComponent”></component > Label, as shown below

Then add a line of <property name=”dynamic.classpath” value=”true” /> to the component tag, it becomes the following

Start the project again and no error will be reported

[Solved] IntelliJ idea error: error: Java does not support release 5

Method 1

1. Confirm to configure Maven

Find the path in Maven home path and find the Maven address \ conf \ setting xml

Select your own JDK version

<profile>
      <id>development</id>
      <activation>
        <jdk>1.8</jdk>
        <activeByDefault>true</activeByDefault>
      </activation>
      <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
      </properties>
    </profile>

Restart idea

Method 2

In project POM Specify the JDK version in the XML file

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>
</properties>