org.springframework.beans.factory.CannotLoadBeanClassException-估计mapper出参 和 po字段不对应了...

本文记录了解决因Java版本不匹配导致的Spring MVC项目启动失败问题的过程。通过调整Java版本、清理项目配置及重置开发环境等步骤,最终成功运行项目。

DEBUG [localhost-startStop-1] - Ignoring bean class loading failure for bean 'itemsService'
org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [cn.itcast.ssm.service.impl.ItemsServiceImpl] for bean with name 'itemsService' defined in ServletContext resource [/WEB-INF/classes/spring/applicationContext-service.xml]: problem with class file or dependent class; nested exception is java.lang.UnsupportedClassVersionError: cn/itcast/ssm/service/impl/ItemsServiceImpl : Unsupported major.minor version 52.0 (unable to load class cn.itcast.ssm.service.impl.ItemsServiceImpl)

七月 31, 2017 8:09:17 下午 org.apache.catalina.core.StandardContext listenerStart
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener

背景:本人周五下班兴致勃勃想把一个以前黑马的mysql小程序改到sqlserver 来,经历:

  1、连接sqlserver异常:Exception in thread "main" com.microsoft.sqlserver.jdbc.SQLServerException: http://www.cnblogs.com/rogge7/p/7253927.html

  2、JDK版本异常1.8降低到1.7,message Servlet.init() for servlet springmvc threw exception

  3、Eclipse版本降低为mars (因为最新oxygen不支持JDK1.7), indigo我都下载好了,

  4、无法解析类型 javax.servlet.http.HttpServletRequest ,http://www.cnblogs.com/rogge7/p/7241456.html 

  5、属性名冲突  ,再db.properties配置文件修改后,

   程序跑起来还是弹出上面异常,再怎么也解决不了,

以为:是Tomcat版本的问题,

    或者是太多的框架jar包整合和现在环境冲突问题(上传图片的 fileupload jar包,json交互jackson包,Validation校验的包)

    重新导入表结构

  后来先做了连接sqlserver数据库,用mybatis官方的代码方法  自动生成 数据库映射文件的,不错。

 

居然:后来思考是否在折腾异常的过程中 把源码搞坏了,找来原来源码,重新配置后果然可以运行起来。晕人。

  不过也是在解决了上面很多问题后才可以跑起来的;同时备份源码很重要。

 

待续...

 

 

 

 

===========

附上面异常,一大版

七月 31, 2017 8:09:08 下午 org.apache.tomcat.util.digester.SetPropertiesRule begin
警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:springmvc_mybatis1208' did not find a matching property.
七月 31, 2017 8:09:08 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server version:        Apache Tomcat/8.0.36
七月 31, 2017 8:09:08 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server built:          Jun 9 2016 13:55:50 UTC
七月 31, 2017 8:09:08 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server number:         8.0.36.0
七月 31, 2017 8:09:08 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Name:               Windows 8.1
七月 31, 2017 8:09:08 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Version:            6.3
七月 31, 2017 8:09:08 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Architecture:          amd64
七月 31, 2017 8:09:08 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Java Home:             C:\Program Files\Java\jre7
七月 31, 2017 8:09:08 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Version:           1.7.0_71-b14
七月 31, 2017 8:09:08 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Vendor:            Oracle Corporation
七月 31, 2017 8:09:08 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_BASE:         F:\Projects\Java\workspaceTest2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
七月 31, 2017 8:09:08 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_HOME:         F:\Projects\Java\tools\apache-tomcat-8.0.36
七月 31, 2017 8:09:08 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:53908
七月 31, 2017 8:09:08 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.base=F:\Projects\Java\workspaceTest2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
七月 31, 2017 8:09:08 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.home=F:\Projects\Java\tools\apache-tomcat-8.0.36
七月 31, 2017 8:09:08 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dwtp.deploy=F:\Projects\Java\workspaceTest2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
七月 31, 2017 8:09:08 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.endorsed.dirs=F:\Projects\Java\tools\apache-tomcat-8.0.36\endorsed
七月 31, 2017 8:09:08 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dfile.encoding=GBK
七月 31, 2017 8:09:08 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre7\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jdk1.7.0_71/bin/../jre/bin/server;C:/Program Files/Java/jdk1.7.0_71/bin/../jre/bin;C:/Program Files/Java/jdk1.7.0_71/bin/../jre/lib/amd64;F:\Projects\Java\tools\apache-maven-3.5.0\bin;C:\Program Files\Java\jdk1.7.0_71\bin;C:\Program Files\Java\jdk1.7.0_71\jre\bin;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;F:\长宝科技\GQ平台\GQClient_New\bin;C:\Program Files (x86)\Borland\Delphi7\Bin;C:\Program Files (x86)\Borland\Delphi7\Projects\Bpl\;C:\ProgramData\oracle\Java\javapath;C:\Program Files (x86)\Embarcadero\Studio\17.0\bin;C:\Users\Public\Documents\Embarcadero\Studio\17.0\Bpl;C:\Program Files (x86)\Embarcadero\Studio\17.0\bin64;C:\Users\Public\Documents\Embarcadero\Studio\17.0\Bpl\Win64;C:\Program Files (x86)\Embarcadero\RAD Studio\9.0\bin;C:\Users\Public\Documents\RAD Studio\9.0\Bpl;C:\Program Files (x86)\Embarcadero\RAD Studio\9.0\bin64;C:\Users\Public\Documents\RAD Studio\9.0\Bpl\Win64;d:\Program Files (x86)\Embarcadero\RAD Studio\9.0\bin;d:\Program Files (x86)\Embarcadero\RAD Studio\9.0\bin64;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Lenovo\Bluetooth Software\;C:\Program Files\Lenovo\Bluetooth Software\syswow64;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Microsoft ASP.NET\ASP.net Web Pages\v1.0\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\TortoiseSVN\bin;C:\Users\yc\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;D:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;D:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;c:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\;C:\Users\yc\AppData\Local\Microsoft\WindowsApps;;F:\Projects\Java\tools\eclipse;;.
七月 31, 2017 8:09:08 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["http-nio-8080"]
七月 31, 2017 8:09:08 下午 org.apache.tomcat.util.Net.NioSelectorPool getSharedSelector
信息: Using a shared selector for servlet write/read
七月 31, 2017 8:09:08 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["ajp-nio-8009"]
七月 31, 2017 8:09:08 下午 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
信息: Using a shared selector for servlet write/read
七月 31, 2017 8:09:08 下午 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 1830 ms
七月 31, 2017 8:09:08 下午 org.apache.catalina.core.StandardService startInternal
信息: Starting service Catalina
七月 31, 2017 8:09:08 下午 org.apache.catalina.core.StandardEngine startInternal
信息: Starting Servlet Engine: Apache Tomcat/8.0.36
七月 31, 2017 8:09:10 下午 org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom
信息: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [461] milliseconds.
七月 31, 2017 8:09:15 下午 org.apache.jasper.servlet.TldScanner scanJars
信息: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
七月 31, 2017 8:09:15 下午 org.apache.catalina.core.ApplicationContext log
信息: No spring WebApplicationInitializer types detected on classpath
七月 31, 2017 8:09:15 下午 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
 INFO [localhost-startStop-1] - Root WebApplicationContext: initialization started
DEBUG [localhost-startStop-1] - Initializing new StandardServletEnvironment
DEBUG [localhost-startStop-1] - Adding [servletConfigInitParams] PropertySource with lowest search precedence
DEBUG [localhost-startStop-1] - Adding [servletContextInitParams] PropertySource with lowest search precedence
DEBUG [localhost-startStop-1] - Adding [jndiProperties] PropertySource with lowest search precedence
DEBUG [localhost-startStop-1] - Adding [systemProperties] PropertySource with lowest search precedence
DEBUG [localhost-startStop-1] - Adding [systemEnvironment] PropertySource with lowest search precedence
DEBUG [localhost-startStop-1] - Initialized StandardServletEnvironment with PropertySources [servletConfigInitParams,servletContextInitParams,jndiProperties,systemProperties,systemEnvironment]
 INFO [localhost-startStop-1] - Refreshing Root WebApplicationContext: startup date [Mon Jul 31 20:09:15 CST 2017]; root of context hierarchy
DEBUG [localhost-startStop-1] - Replacing [servletContextInitParams] PropertySource with [servletContextInitParams]
DEBUG [localhost-startStop-1] - Initializing new StandardEnvironment
DEBUG [localhost-startStop-1] - Adding [systemProperties] PropertySource with lowest search precedence
DEBUG [localhost-startStop-1] - Adding [systemEnvironment] PropertySource with lowest search precedence
DEBUG [localhost-startStop-1] - Initialized StandardEnvironment with PropertySources [systemProperties,systemEnvironment]
DEBUG [localhost-startStop-1] - Initializing new StandardEnvironment
DEBUG [localhost-startStop-1] - Adding [systemProperties] PropertySource with lowest search precedence
DEBUG [localhost-startStop-1] - Adding [systemEnvironment] PropertySource with lowest search precedence
DEBUG [localhost-startStop-1] - Initialized StandardEnvironment with PropertySources [systemProperties,systemEnvironment]
DEBUG [localhost-startStop-1] - Resolved location pattern [/WEB-INF/classes/spring/applicationContext-*.xml] to resources [ServletContext resource [/WEB-INF/classes/spring/applicationContext-dao.xml], ServletContext resource [/WEB-INF/classes/spring/applicationContext-service.xml], ServletContext resource [/WEB-INF/classes/spring/applicationContext-transaction.xml]]
 INFO [localhost-startStop-1] - Loading XML bean definitions from ServletContext resource [/WEB-INF/classes/spring/applicationContext-dao.xml]
DEBUG [localhost-startStop-1] - Using JAXP provider [com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl]
DEBUG [localhost-startStop-1] - Loading schema mappings from [META-INF/spring.schemas]
DEBUG [localhost-startStop-1] - Loaded schema mappings: {http://mybatis.org/schema/mybatis-spring-1.2.xsd=org/mybatis/spring/config/mybatis-spring-1.2.xsd, http://www.springframework.org/schema/jee/spring-jee-3.2.xsd=org/springframework/ejb/config/spring-jee-3.2.xsd, http://www.springframework.org/schema/util/spring-util.xsd=org/springframework/beans/factory/xml/spring-util-3.2.xsd, http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd=org/springframework/web/servlet/config/spring-mvc-3.1.xsd, http://www.springframework.org/schema/task/spring-task.xsd=org/springframework/scheduling/config/spring-task-3.2.xsd, http://www.springframework.org/schema/beans/spring-beans-3.1.xsd=org/springframework/beans/factory/xml/spring-beans-3.1.xsd, http://www.springframework.org/schema/cache/spring-cache.xsd=org/springframework/cache/config/spring-cache-3.2.xsd, http://www.springframework.org/schema/aop/spring-aop-3.0.xsd=org/springframework/aop/config/spring-aop-3.0.xsd, http://www.springframework.org/schema/task/spring-task-3.1.xsd=org/springframework/scheduling/config/spring-task-3.1.xsd, http://www.springframework.org/schema/aop/spring-aop-2.0.xsd=org/springframework/aop/config/spring-aop-2.0.xsd, http://www.springframework.org/schema/tool/spring-tool-2.5.xsd=org/springframework/beans/factory/xml/spring-tool-2.5.xsd, http://www.springframework.org/schema/beans/spring-beans.xsd=org/springframework/beans/factory/xml/spring-beans-3.2.xsd, http://www.springframework.org/schema/jee/spring-jee-2.5.xsd=org/springframework/ejb/config/spring-jee-2.5.xsd, http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd=org/springframework/jdbc/config/spring-jdbc-3.1.xsd, http://www.springframework.org/schema/tool/spring-tool-3.1.xsd=org/springframework/beans/factory/xml/spring-tool-3.1.xsd, http://www.springframework.org/schema/jee/spring-jee-3.1.xsd=org/springframework/ejb/config/spring-jee-3.1.xsd, http://www.springframework.org/schema/aop/spring-aop.xsd=org/springframework/aop/config/spring-aop-3.2.xsd, http://www.springframework.org/schema/tx/spring-tx-3.2.xsd=org/springframework/transaction/config/spring-tx-3.2.xsd, http://www.springframework.org/schema/context/spring-context-3.2.xsd=org/springframework/context/config/spring-context-3.2.xsd, http://www.springframework.org/schema/beans/spring-beans-2.0.xsd=org/springframework/beans/factory/xml/spring-beans-2.0.xsd, http://www.springframework.org/schema/util/spring-util-3.2.xsd=org/springframework/beans/factory/xml/spring-util-3.2.xsd, http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd=org/springframework/web/servlet/config/spring-mvc-3.0.xsd, http://www.springframework.org/schema/lang/spring-lang-3.2.xsd=org/springframework/scripting/config/spring-lang-3.2.xsd, http://www.springframework.org/schema/beans/spring-beans-3.0.xsd=org/springframework/beans/factory/xml/spring-beans-3.0.xsd, http://www.springframework.org/schema/cache/spring-cache-3.2.xsd=org/springframework/cache/config/spring-cache-3.2.xsd, http://www.springframework.org/schema/task/spring-task-3.0.xsd=org/springframework/scheduling/config/spring-task-3.0.xsd, http://mybatis.org/schema/mybatis-spring.xsd=org/mybatis/spring/config/mybatis-spring-1.2.xsd, http://www.springframework.org/schema/tx/spring-tx-2.5.xsd=org/springframework/transaction/config/spring-tx-2.5.xsd, http://www.springframework.org/schema/context/spring-context-2.5.xsd=org/springframework/context/config/spring-context-2.5.xsd, http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd=org/springframework/jdbc/config/spring-jdbc-3.0.xsd, http://www.springframework.org/schema/tool/spring-tool-3.0.xsd=org/springframework/beans/factory/xml/spring-tool-3.0.xsd, http://www.springframework.org/schema/tx/spring-tx.xsd=org/springframework/transaction/config/spring-tx-3.2.xsd, http://www.springframework.org/schema/lang/spring-lang.xsd=org/springframework/scripting/config/spring-lang-3.2.xsd, http://www.springframework.org/schema/tool/spring-tool-2.0.xsd=org/springframework/beans/factory/xml/spring-tool-2.0.xsd, http://www.springframework.org/schema/util/spring-util-2.5.xsd=org/springframework/beans/factory/xml/spring-util-2.5.xsd, http://www.springframework.org/schema/lang/spring-lang-2.5.xsd=org/springframework/scripting/config/spring-lang-2.5.xsd, http://www.springframework.org/schema/aop/spring-aop-3.2.xsd=org/springframework/aop/config/spring-aop-3.2.xsd, http://www.springframework.org/schema/jee/spring-jee-3.0.xsd=org/springframework/ejb/config/spring-jee-3.0.xsd, http://www.springframework.org/schema/tx/spring-tx-3.1.xsd=org/springframework/transaction/config/spring-tx-3.1.xsd, http://www.springframework.org/schema/jee/spring-jee-2.0.xsd=org/springframework/ejb/config/spring-jee-2.0.xsd, http://www.springframework.org/schema/context/spring-context-3.1.xsd=org/springframework/context/config/spring-context-3.1.xsd, http://www.springframework.org/schema/util/spring-util-3.1.xsd=org/springframework/beans/factory/xml/spring-util-3.1.xsd, http://www.springframework.org/schema/lang/spring-lang-3.1.xsd=org/springframework/scripting/config/spring-lang-3.1.xsd, http://www.springframework.org/schema/cache/spring-cache-3.1.xsd=org/springframework/cache/config/spring-cache-3.1.xsd, http://www.springframework.org/schema/context/spring-context.xsd=org/springframework/context/config/spring-context-3.2.xsd, http://www.springframework.org/schema/jee/spring-jee.xsd=org/springframework/ejb/config/spring-jee-3.2.xsd, http://www.springframework.org/schema/aop/spring-aop-2.5.xsd=org/springframework/aop/config/spring-aop-2.5.xsd, http://www.springframework.org/schema/mvc/spring-mvc.xsd=org/springframework/web/servlet/config/spring-mvc-3.2.xsd, http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd=org/springframework/web/servlet/config/spring-mvc-3.2.xsd, http://www.springframework.org/schema/jdbc/spring-jdbc.xsd=org/springframework/jdbc/config/spring-jdbc-3.2.xsd, http://www.springframework.org/schema/beans/spring-beans-3.2.xsd=org/springframework/beans/factory/xml/spring-beans-3.2.xsd, http://www.springframework.org/schema/tx/spring-tx-2.0.xsd=org/springframework/transaction/config/spring-tx-2.0.xsd, http://www.springframework.org/schema/aop/spring-aop-3.1.xsd=org/springframework/aop/config/spring-aop-3.1.xsd, http://www.springframework.org/schema/task/spring-task-3.2.xsd=org/springframework/scheduling/config/spring-task-3.2.xsd, http://www.springframework.org/schema/tx/spring-tx-3.0.xsd=org/springframework/transaction/config/spring-tx-3.0.xsd, http://www.springframework.org/schema/context/spring-context-3.0.xsd=org/springframework/context/config/spring-context-3.0.xsd, http://www.springframework.org/schema/tool/spring-tool.xsd=org/springframework/beans/factory/xml/spring-tool-3.2.xsd, http://www.springframework.org/schema/util/spring-util-3.0.xsd=org/springframework/beans/factory/xml/spring-util-3.0.xsd, http://www.springframework.org/schema/lang/spring-lang-3.0.xsd=org/springframework/scripting/config/spring-lang-3.0.xsd, http://www.springframework.org/schema/util/spring-util-2.0.xsd=org/springframework/beans/factory/xml/spring-util-2.0.xsd, http://www.springframework.org/schema/lang/spring-lang-2.0.xsd=org/springframework/scripting/config/spring-lang-2.0.xsd, http://www.springframework.org/schema/jdbc/spring-jdbc-3.2.xsd=org/springframework/jdbc/config/spring-jdbc-3.2.xsd, http://www.springframework.org/schema/tool/spring-tool-3.2.xsd=org/springframework/beans/factory/xml/spring-tool-3.2.xsd, http://www.springframework.org/schema/beans/spring-beans-2.5.xsd=org/springframework/beans/factory/xml/spring-beans-2.5.xsd}
DEBUG [localhost-startStop-1] - Found XML schema [http://www.springframework.org/schema/beans/spring-beans-3.2.xsd] in classpath: org/springframework/beans/factory/xml/spring-beans-3.2.xsd
DEBUG [localhost-startStop-1] - Found XML schema [http://www.springframework.org/schema/context/spring-context-3.2.xsd] in classpath: org/springframework/context/config/spring-context-3.2.xsd
DEBUG [localhost-startStop-1] - Found XML schema [http://www.springframework.org/schema/tool/spring-tool-3.2.xsd] in classpath: org/springframework/beans/factory/xml/spring-tool-3.2.xsd
DEBUG [localhost-startStop-1] - Loading bean definitions
DEBUG [localhost-startStop-1] - Loaded NamespaceHandler mappings: {http://www.springframework.org/schema/p=org.springframework.beans.factory.xml.SimplePropertyNamespaceHandler, http://www.springframework.org/schema/mvc=org.springframework.web.servlet.config.MvcNamespaceHandler, http://www.springframework.org/schema/util=org.springframework.beans.factory.xml.UtilNamespaceHandler, http://www.springframework.org/schema/jee=org.springframework.ejb.config.JeeNamespaceHandler, http://www.springframework.org/schema/aop=org.springframework.aop.config.AopNamespaceHandler, http://www.springframework.org/schema/jdbc=org.springframework.jdbc.config.JdbcNamespaceHandler, http://www.springframework.org/schema/cache=org.springframework.cache.config.CacheNamespaceHandler, http://mybatis.org/schema/mybatis-spring=org.mybatis.spring.config.NamespaceHandler, http://www.springframework.org/schema/c=org.springframework.beans.factory.xml.SimpleConstructorNamespaceHandler, http://www.springframework.org/schema/tx=org.springframework.transaction.config.TxNamespaceHandler, http://www.springframework.org/schema/task=org.springframework.scheduling.config.TaskNamespaceHandler, http://www.springframework.org/schema/lang=org.springframework.scripting.config.LangNamespaceHandler, http://www.springframework.org/schema/context=org.springframework.context.config.ContextNamespaceHandler}
DEBUG [localhost-startStop-1] - Neither XML 'id' nor 'name' specified - using generated bean name [org.mybatis.spring.mapper.MapperScannerConfigurer#0]
 INFO [localhost-startStop-1] - Loading XML bean definitions from ServletContext resource [/WEB-INF/classes/spring/applicationContext-service.xml]
DEBUG [localhost-startStop-1] - Using JAXP provider [com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl]
DEBUG [localhost-startStop-1] - Found XML schema [http://www.springframework.org/schema/beans/spring-beans-3.2.xsd] in classpath: org/springframework/beans/factory/xml/spring-beans-3.2.xsd
DEBUG [localhost-startStop-1] - Loading bean definitions
 INFO [localhost-startStop-1] - Loading XML bean definitions from ServletContext resource [/WEB-INF/classes/spring/applicationContext-transaction.xml]
DEBUG [localhost-startStop-1] - Using JAXP provider [com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl]
DEBUG [localhost-startStop-1] - Found XML schema [http://www.springframework.org/schema/beans/spring-beans-3.2.xsd] in classpath: org/springframework/beans/factory/xml/spring-beans-3.2.xsd
DEBUG [localhost-startStop-1] - Found XML schema [http://www.springframework.org/schema/tx/spring-tx-3.2.xsd] in classpath: org/springframework/transaction/config/spring-tx-3.2.xsd
DEBUG [localhost-startStop-1] - Found XML schema [http://www.springframework.org/schema/tool/spring-tool-3.2.xsd] in classpath: org/springframework/beans/factory/xml/spring-tool-3.2.xsd
DEBUG [localhost-startStop-1] - Found XML schema [http://www.springframework.org/schema/aop/spring-aop-3.2.xsd] in classpath: org/springframework/aop/config/spring-aop-3.2.xsd
DEBUG [localhost-startStop-1] - Loading bean definitions
DEBUG [localhost-startStop-1] - Loaded 9 bean definitions from location pattern [/WEB-INF/classes/spring/applicationContext-*.xml]
DEBUG [localhost-startStop-1] - Bean factory for Root WebApplicationContext: org.springframework.beans.factory.support.DefaultListableBeanFactory@2f098b2: defining beans [org.springframework.context.support.PropertySourcesPlaceholderConfigurer#0,dataSource,sqlSessionFactory,org.mybatis.spring.mapper.MapperScannerConfigurer#0,itemsService,transactionManager,txAdvice,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0]; root of factory hierarchy
DEBUG [localhost-startStop-1] - Ignoring bean class loading failure for bean 'itemsService'
org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [cn.itcast.ssm.service.impl.ItemsServiceImpl] for bean with name 'itemsService' defined in ServletContext resource [/WEB-INF/classes/spring/applicationContext-service.xml]: problem with class file or dependent class; nested exception is java.lang.UnsupportedClassVersionError: cn/itcast/ssm/service/impl/ItemsServiceImpl : Unsupported major.minor version 52.0 (unable to load class cn.itcast.ssm.service.impl.ItemsServiceImpl)
 at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1266)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:581)
 at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1332)
 at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:337)
 at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:308)
 at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:416)
 at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:624)
 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461)
 at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383)
 at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
 at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
 at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4842)
 at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5303)
 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
 at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1407)
 at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1397)
 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)
Caused by: java.lang.UnsupportedClassVersionError: cn/itcast/ssm/service/impl/ItemsServiceImpl : Unsupported major.minor version 52.0 (unable to load class cn.itcast.ssm.service.impl.ItemsServiceImpl)
 at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2544)
 at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:858)
 at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1301)
 at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1166)
 at org.springframework.util.ClassUtils.forName(ClassUtils.java:258)
 at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:415)
 at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1284)
 at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1255)
 ... 19 more
DEBUG [localhost-startStop-1] - Creating shared instance of singleton bean 'org.mybatis.spring.mapper.MapperScannerConfigurer#0'
DEBUG [localhost-startStop-1] - Creating instance of bean 'org.mybatis.spring.mapper.MapperScannerConfigurer#0'
DEBUG [localhost-startStop-1] - Eagerly caching bean 'org.mybatis.spring.mapper.MapperScannerConfigurer#0' to allow for resolving potential circular references
DEBUG [localhost-startStop-1] - Invoking afterPropertiesSet() on bean with name 'org.mybatis.spring.mapper.MapperScannerConfigurer#0'
DEBUG [localhost-startStop-1] - Finished creating instance of bean 'org.mybatis.spring.mapper.MapperScannerConfigurer#0'
DEBUG [localhost-startStop-1] - Initializing new StandardEnvironment
DEBUG [localhost-startStop-1] - Adding [systemProperties] PropertySource with lowest search precedence
DEBUG [localhost-startStop-1] - Adding [systemEnvironment] PropertySource with lowest search precedence
DEBUG [localhost-startStop-1] - Initialized StandardEnvironment with PropertySources [systemProperties,systemEnvironment]
DEBUG [localhost-startStop-1] - Looking for matching resources in directory tree [F:\Projects\Java\workspaceTest2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\springmvc_mybatis1208\WEB-INF\classes\cn\itcast\ssm\mapper]
DEBUG [localhost-startStop-1] - Searching directory [F:\Projects\Java\workspaceTest2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\springmvc_mybatis1208\WEB-INF\classes\cn\itcast\ssm\mapper] for files matching pattern [F:/Projects/Java/workspaceTest2/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/springmvc_mybatis1208/WEB-INF/classes/cn/itcast/ssm/mapper/**/*.class]
DEBUG [localhost-startStop-1] - Resolved location pattern [classpath*:cn/itcast/ssm/mapper/**/*.class] to resources [file [F:\Projects\Java\workspaceTest2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\springmvc_mybatis1208\WEB-INF\classes\cn\itcast\ssm\mapper\ItemsMapper.class], file [F:\Projects\Java\workspaceTest2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\springmvc_mybatis1208\WEB-INF\classes\cn\itcast\ssm\mapper\ItemsMapperCustom.class], file [F:\Projects\Java\workspaceTest2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\springmvc_mybatis1208\WEB-INF\classes\cn\itcast\ssm\mapper\OrderdetailMapper.class], file [F:\Projects\Java\workspaceTest2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\springmvc_mybatis1208\WEB-INF\classes\cn\itcast\ssm\mapper\OrdersMapper.class], file [F:\Projects\Java\workspaceTest2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\springmvc_mybatis1208\WEB-INF\classes\cn\itcast\ssm\mapper\UserMapper.class]]
 INFO [localhost-startStop-1] - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@2f098b2: defining beans [org.springframework.context.support.PropertySourcesPlaceholderConfigurer#0,dataSource,sqlSessionFactory,org.mybatis.spring.mapper.MapperScannerConfigurer#0,itemsService,transactionManager,txAdvice,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0]; root of factory hierarchy
ERROR [localhost-startStop-1] - Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [F:\Projects\Java\workspaceTest2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\springmvc_mybatis1208\WEB-INF\classes\cn\itcast\ssm\mapper\ItemsMapper.class]; nested exception is java.lang.IllegalArgumentException
 at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:281)
 at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:242)
 at org.mybatis.spring.mapper.ClassPathMapperScanner.doScan(ClassPathMapperScanner.java:155)
 at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.scan(ClassPathBeanDefinitionScanner.java:220)
 at org.mybatis.spring.mapper.MapperScannerConfigurer.postProcessBeanDefinitionRegistry(MapperScannerConfigurer.java:315)
 at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:630)
 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461)
 at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383)
 at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
 at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
 at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4842)
 at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5303)
 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
 at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1407)
 at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1397)
 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)
Caused by: java.lang.IllegalArgumentException
 at org.springframework.asm.ClassReader.<init>(Unknown Source)
 at org.springframework.asm.ClassReader.<init>(Unknown Source)
 at org.springframework.asm.ClassReader.<init>(Unknown Source)
 at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:52)
 at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:80)
 at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:101)
 at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:257)
 ... 18 more
七月 31, 2017 8:09:17 下午 org.apache.catalina.core.StandardContext listenerStart
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [F:\Projects\Java\workspaceTest2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\springmvc_mybatis1208\WEB-INF\classes\cn\itcast\ssm\mapper\ItemsMapper.class]; nested exception is java.lang.IllegalArgumentException
 at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:281)
 at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:242)
 at org.mybatis.spring.mapper.ClassPathMapperScanner.doScan(ClassPathMapperScanner.java:155)
 at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.scan(ClassPathBeanDefinitionScanner.java:220)
 at org.mybatis.spring.mapper.MapperScannerConfigurer.postProcessBeanDefinitionRegistry(MapperScannerConfigurer.java:315)
 at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:630)
 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461)
 at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383)
 at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
 at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
 at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4842)
 at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5303)
 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
 at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1407)
 at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1397)
 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)
Caused by: java.lang.IllegalArgumentException
 at org.springframework.asm.ClassReader.<init>(Unknown Source)
 at org.springframework.asm.ClassReader.<init>(Unknown Source)
 at org.springframework.asm.ClassReader.<init>(Unknown Source)
 at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:52)
 at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:80)
 at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:101)
 at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents
(ClassPathScanningCandidateComponentProvider.java:
257) ... 18 more 七月 31, 2017 8:09:17 下午 org.apache.catalina.core.StandardContext startInternal 严重: One or more listeners failed to start. Full details will be found in the appropriate Container log file 七月 31, 2017 8:09:17 下午 org.apache.catalina.core.StandardContext startInternal 严重: Context [/springmvc_mybatis1208] startup failed due to previous errors 七月 31, 2017 8:09:17 下午 org.apache.catalina.core.ApplicationContext log 信息: Closing Spring root WebApplicationContext 七月 31, 2017 8:09:17 下午 org.apache.coyote.AbstractProtocol start 信息: Starting ProtocolHandler ["http-nio-8080"] 七月 31, 2017 8:09:17 下午 org.apache.coyote.AbstractProtocol start 信息: Starting ProtocolHandler ["ajp-nio-8009"] 七月 31, 2017 8:09:17 下午 org.apache.catalina.startup.Catalina start 信息: Server startup in 8366 ms

 

org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘xmcLcdpItemMapper’ defined in file [D:\h0-lcdp\target\classes\com\hand\xmc\infra\mapper\XmcLcdpItemMapper.class]: io.choerodon.mybatis.MapperException: java.lang.IllegalArgumentException: com.hand.xmc.infra.mapper.XmcLcdpItemMapper.insertListAssignKey对应的实体类com.hand.xmc.domain.entity.XmcLcdpItem中包含多个自动增长列,最多只能有一个! at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1808) ~[spring-beans-6.2.1.jar:6.2.1] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:601) ~[spring-beans-6.2.1.jar:6.2.1] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:523) ~[spring-beans-6.2.1.jar:6.2.1] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:336) ~[spring-beans-6.2.1.jar:6.2.1] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:289) ~[spring-beans-6.2.1.jar:6.2.1] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:334) ~[spring-beans-6.2.1.jar:6.2.1] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-6.2.1.jar:6.2.1] package com.hand.xmc.domain.entity; import com.fasterxml.jackson.annotation.JsonInclude; import io.choerodon.mybatis.annotation.ModifyAudit; import io.choerodon.mybatis.annotation.VersionAudit; import io.choerodon.mybatis.domain.AuditDomain; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Table; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import java.math.BigDecimal; import java.util.Date; import lombok.Getter; import lombok.Setter; /** LCDP请求明细项表(XmcLcdpItem)实体类 @author maoxiong @since 2025-08-18 13:32:22 */ @Getter @Setter @ApiModel(“LCDP请求明细项表”) @VersionAudit @ModifyAudit @JsonInclude(value = JsonInclude.Include.NON_NULL) @Table(name = “XMC_LCDP_ITEM”) public class XmcLcdpItem extends AuditDomain { private static final long serialVersionUID = -82884834750033649L; public static final String FIELD_ID = "id"; public static final String FIELD_LCDP_REQUEST_ID = "lcdpRequestId"; public static final String FIELD_PO_ITEM_NO = "poItemNo"; public static final String FIELD_ITEM_QTY = "itemQty"; public static final String FIELD_ITEM_AMOUNT = "itemAmount"; public static final String FIELD_SHIPMENT_DATE = "shipmentDate"; public static final String FIELD_MC_DESC = "mcDesc"; public static final String FIELD_UNIT = "unit"; public static final String FIELD_EQ_ID = "eqId"; public static final String FIELD_EQ_STATUS = "eqStatus"; public static final String FIELD_DELIV_DATE = "delivDate"; public static final String FIELD_CREATED_AT = "createdAt"; public static final String FIELD_UPDATED_AT = "updatedAt"; public static final String FIELD_UPDATED_BY = "updatedBy"; public static final String FIELD_VERSION = "version"; public static final String FIELD_IS_DELETED = "isDeleted"; public static final String FIELD_TENANT_ID = "tenantId"; @ApiModelProperty("主键ID") @Id @GeneratedValue private Long id; @ApiModelProperty(value = "关联的LCDP请求ID", required = true) @NotNull private Long lcdpRequestId; @ApiModelProperty(value = "采购订单行号") private String poItemNo; @ApiModelProperty(value = "数量") private Long itemQty; @ApiModelProperty(value = "金额") private Long itemAmount; @ApiModelProperty(value = "发货日期") private Date shipmentDate; @ApiModelProperty(value = "物料描述") private String mcDesc; @ApiModelProperty(value = "单位") private String unit; @ApiModelProperty(value = "设备ID") private String eqId; @ApiModelProperty(value = "设备状态") private String eqStatus; @ApiModelProperty(value = "交货日期") private Date delivDate; @ApiModelProperty(value = "创建时间") private Date createdAt; @ApiModelProperty(value = "更新时间") private Date updatedAt; @ApiModelProperty(value = "更新人") private String updatedBy; @ApiModelProperty(value = "版本号(用于乐观锁)") private Long version; @ApiModelProperty(value = "逻辑删除标识") private String isDeleted; @ApiModelProperty(value = "租户ID", required = true) @NotNull private Long tenantId; } 怎么改
最新发布
08-22
package com.iuit.agent.service.impl; import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.iuit.agent.config.AiChatMemory; import com.iuit.agent.controller.req.Message; import com.iuit.agent.domain.PluginTool; import com.iuit.agent.domain.dto.DocFileDto; import com.iuit.agent.mapper.AgentMapper; import com.iuit.agent.mapper.DocFileMapper; import com.iuit.agent.mapper.PluginToolMapper; import com.iuit.agent.pojo.po.Agent; import com.iuit.agent.result.Result; import com.iuit.agent.service.AgentService; import com.iuit.agent.utils.ChatClientUtils; import com.iuit.agent.utils.NameUtils; import com.iuit.common.core.domain.AjaxResult; import com.iuit.framework.security.context.AuthenticationContextHolder; import org.springframework.ai.chat.client.ChatClient; import org.springframework.ai.chat.client.advisor.MessageChatMemoryAdvisor; import org.springframework.ai.chat.client.advisor.vectorstore.QuestionAnswerAdvisor; import org.springframework.ai.chat.prompt.PromptTemplate; import org.springframework.ai.tool.ToolCallback; import org.springframework.ai.tool.ToolCallbackProvider; import org.springframework.ai.vectorstore.SearchRequest; import org.springframework.ai.vectorstore.VectorStore; import org.springframework.ai.vectorstore.filter.FilterExpressionBuilder; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import java.util.*; /** * (Agent)表服务实现类 * * @author duola * @since 2025-07-02 11:11:57 */ @Service("agentService") public class AgentServiceImpl implements AgentService { @Autowired private AgentMapper agentMapper; @Autowired private ToolCallbackProvider toolCallbackProvider; @Autowired private VectorStore milvusVectorStore; @Autowired private AiChatMemory aiChatMemory; @Autowired private PluginToolMapper pluginToolMapper; @Autowired private DocFileMapper docFileMapper; /** * 通过ID查询单条数据 * * @param id 主键 * @return 实例对象 */ @Override public AjaxResult getAgent(Integer id) { return Optional.ofNullable(agentMapper.selectById(id)) .map(agent -> { // if (!agent.getCreateBy().isEmpty()) { // agent.setCreateName(NameUtils.getFullName(Long.valueOf(agent.getCreateBy()))); // agent.setUpdateName(NameUtils.getFullName(Long.valueOf(agent.getUpdateBy()))); // } return AjaxResult.success(agent); }) .orElse(AjaxResult.warn("存在")); } /** * 分页查询 * * @param * @param * @return */ @Override public AjaxResult getAllAgent(Map<String, Object> params) { Integer page = (Integer) params.get("page"); Integer size = (Integer) params.get("size"); QueryWrapper<Agent> queryWrapper = new QueryWrapper<>(); params.forEach((k, v) -> { if (!(k.equals("page") || k.equals("size"))) { queryWrapper.like(k, String.valueOf(v).replace("%", "\\%").replace("_", "\\_")); } }); PageHelper.startPage(page, size); List<Agent> agentPage = agentMapper.selectList(queryWrapper.orderByDesc("id")); // agentPage.getRecords() // .forEach(agent -> // { // if (!agent.getCreateBy().isEmpty()) { // agent.setCreateName(NameUtils.getFullName(Long.valueOf(agent.getCreateBy()))); // agent.setUpdateName(NameUtils.getFullName(Long.valueOf(agent.getUpdateBy()))); // } // }); return AjaxResult.success(new PageInfo<Agent>(agentPage)); } @Override public Flux<String> chat(Message message) { Agent agent = agentMapper.selectById(message.getAgentId()); ChatClient chatClient = ChatClientUtils.getChatClient(agent); ChatClient.ChatClientRequestSpec prompt = chatClient.prompt(); List<ToolCallback> toolCallbacks = toolCallbacks(agent); List<Integer> list = Arrays.stream(agent.getDatasource().split(",")).map(NumberUtil::parseInt).toList(); ; ArrayList<String> datasource = new ArrayList<>(); datasource(list, datasource); MessageChatMemoryAdvisor messageChatMemoryAdvisor = MessageChatMemoryAdvisor.builder(aiChatMemory) .conversationId(message.getSessionId()) .build(); if (!datasource.isEmpty()) { FilterExpressionBuilder b = new FilterExpressionBuilder(); String content = """ {query} Context information is below, surrounded by --------------------- --------------------- {question_answer_context} --------------------- Given the context and provided history information and not prior knowledge, reply to the user comment. If the answer is not in the context, inform the user that you can't answer the question. """; QuestionAnswerAdvisor answerAdvisor = QuestionAnswerAdvisor.builder(milvusVectorStore) .searchRequest(SearchRequest.builder() .filterExpression(b.in("fileId", datasource).build()) .topK(agent.getSearchNum()) .similarityThreshold(agent.getCorrelationThreshold()) .build()) .promptTemplate(PromptTemplate.builder() .template(content) .build()) .build(); prompt.advisors(answerAdvisor); } prompt.advisors(messageChatMemoryAdvisor); return prompt .system(agent.getPrompt()) .toolCallbacks(toolCallbacks) .user(message.getContent()) .stream() .content().concatWith(Mono.just("end")); } private List<ToolCallback> toolCallbacks(Agent agent) { // List<String> list = pluginToolMapper.selectList(new QueryWrapper<PluginTool>() // .select("tool_name") // .in("plugin_id", agent.getTools().split(","))) // .stream().map(PluginTool::getToolName) // .toList(); List<String> list = Arrays.stream(agent.getTools().split(",")) .distinct() .toList(); return Arrays.stream(toolCallbackProvider.getToolCallbacks()) .filter(toolCallback -> { return list.contains(toolCallback.getToolDefinition().name().replace("client_server1_", "")); }).toList(); } private void datasource(List<Integer> ids, List<String> datasource) { if (ids.isEmpty()) { return; } List<DocFileDto> docFileDtos = docFileMapper.getDocFileByIds(ids); for (DocFileDto docFileDto : docFileDtos) { if (ObjectUtil.isNotNull(docFileDto.getFileLocation())) datasource.add(docFileDto.getFileLocation()); else datasource(docFileMapper .getDocFileByParentId(docFileDto.getId()) .stream() .map(docFileDto1 -> { return Integer.parseInt(docFileDto1.getId().toString()); }) .toList(), datasource); } } /** * 新增数据 * * @param * @return */ @Override public AjaxResult createAgent(Agent agent) { if (agentMapper.selectCount(new QueryWrapper<Agent>() .eq("name", agent.getName())) > 0) return AjaxResult.warn("名称重复", null); if (agentMapper.selectCount(new QueryWrapper<Agent>() .eq("identify", agent.getIdentify())) > 0) return AjaxResult.warn("标识重复", null); // if (AuthenticationContextHolder.get() != null) { // agent.setUpdateBy(threadLocal.get().getId().toString()); // agent.setCreateBy(threadLocal.get().getId().toString()); // } int insert = agentMapper.insert(agent); return insert > 0 ? AjaxResult.success("成功创建") : AjaxResult.warn("创建失败", null); } /** * 修改数据 * * @param * @return */ @Override public AjaxResult updateAgent(Agent agent) { if (agentMapper.selectCount(new QueryWrapper<Agent>() .eq("name", agent.getName()) .ne("id", agent.getId())) > 0) return AjaxResult.warn("名称重复", null); if (agentMapper.selectCount(new QueryWrapper<Agent>() .eq("identify", agent.getIdentify()) .ne("id", agent.getId())) > 0) return AjaxResult.warn("标识重复", null); // if (threadLocal.get() != null) // agent.setUpdateBy(threadLocal.get().getId().toString()); int i = agentMapper.updateById(agent); return i > 0 ? AjaxResult.success("更新成功") : AjaxResult.warn("更新失败", null); } /** * 通过主键删除数据 * * @param * @return 是否成功 */ @Override public AjaxResult deleteAgent(Integer id) { int i = agentMapper.deleteById(id); return i > 0 ? AjaxResult.success("删除成功") : AjaxResult.warn("删除失败"); } } package com.iuit.agent.config; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.iuit.agent.mapper.AiMessageMapper; import com.iuit.agent.pojo.po.AiMessage; import lombok.AllArgsConstructor; import org.springframework.ai.chat.memory.ChatMemory; import org.springframework.ai.chat.messages.AssistantMessage; import org.springframework.ai.chat.messages.Message; import org.springframework.ai.chat.messages.SystemMessage; import org.springframework.ai.chat.messages.UserMessage; import org.springframework.stereotype.Component; import java.util.Comparator; import java.util.List; @Component @AllArgsConstructor public class AiChatMemory implements ChatMemory { private AiMessageMapper aiMessageMapper; @Override public void add(String conversationId, List<Message> messages) { for (Message message : messages) { AiMessage aiMessage = new AiMessage(); aiMessage.setAiSessionId(conversationId); aiMessage.setType(message.getMessageType().toString()); aiMessage.setTextContent(message.getText()); if (message.getText().contains("</think>")) aiMessage.setTextContent(message.getText().split("</think>")[1]); aiMessageMapper.insert(aiMessage); } } @Override public List<Message> get(String conversationId) { return aiMessageMapper.selectList(new QueryWrapper<AiMessage>() .eq("ai_session_id", conversationId).orderByDesc("id").last("limit " + 4) ) .stream() .sorted(Comparator.comparing(AiMessage::getId)) .map(this::toMessage) .toList(); } @Override public void clear(String conversationId) { aiMessageMapper.delete(new QueryWrapper<AiMessage>() .eq("ai_session_id", conversationId)); } private Message toMessage(AiMessage aiMessage) { return switch (aiMessage.getType()) { case "USER" -> new UserMessage(aiMessage.getTextContent()); case "SYSTEM" -> new SystemMessage(aiMessage.getTextContent()); case "ASSISTANT" -> new AssistantMessage(aiMessage.getTextContent()); default -> null; }; } // private class MyMessage extends AbstractMessage{ // // protected MyMessage(MessageType messageType, String textContent, Map<String, Object> metadata) { // super(messageType, textContent, metadata); // } // } } 请根据上述代码,告诉我如何将ai的思考过程也返回
07-12
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值