【Spring】类存在,初始化却提示ClassNotFound???

事情是这样的,spring配置文件里面写了一组基本的《bean》标签,没有

可以说是很简单了,而且我搜索的时候只有一个,没有重复的
然后启动就ClassNotFound,说找不到这个类,求解

在你确定代码没有问题的时候,你需要考虑下编辑器的编译问题,很多编辑器有时候会不能第一时间把java文件编译成class文件,这个时候就会报这个错误。
你可以去编译过后的target目录下查找是否有你的class文件。
如果是maven的话你去clean,在你install。

你把最终生成的jar包或者是war包解压一下,然后找找,是不是能够找到这个class文件。
1、如果没找到,这种可能性很大,检查一下maven依赖或者说使用shade打包的时候没打进去
2、如果找到了,这种情况比较低,我也没什么想法

配置文件不对

<?xml version="1.0" encoding="UTF-8"?>
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
ssmweb

org.springframework.web.context.ContextLoaderListener


contextConfigLocation
classpath:applicationContext.xml


DispatcherServlet
org.springframework.web.servlet.DispatcherServlet

contextConfigLocation
classpath:applicationContext.xml



DispatcherServlet
*.action

<?xml version="1.0" encoding="UTF-8"?>
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
ssmweb

org.springframework.web.context.ContextLoaderListener


contextConfigLocation
classpath:applicationContext.xml


DispatcherServlet
org.springframework.web.servlet.DispatcherServlet

contextConfigLocation
classpath:applicationContext.xml



DispatcherServlet
*.action


 <?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    version="3.0">
    <display-name>ssmweb</display-name>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:applicationContext.xml</param-value>
    </context-param>
    <servlet>
        <servlet-name>DispatcherServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:applicationContext.xml</param-value>
        </init-param>
    </servlet>
    <servlet-mapping>
        <servlet-name>DispatcherServlet</servlet-name>
        <url-pattern>*.action</url-pattern>
    </servlet-mapping>
</web-app>

检查一下你的bean里面的class路径是不是正确呢

写一个test去测试,如果连实体都报错,那就是引入的包错误或者路径错误,实体没问题,后面的错通过debug一行一行看,先把错误原因找到才能解决问题

需要在配置里写明白,你怎么配置的