走路自带风. 2022-03-26 18:12 采纳率: 80.4%
浏览 332
已结题

工件部署为什么一直出错的,大概是哪里的问题的,该怎么解决这个问题的,是不是因为存在多个上下文导致的

问题遇到的现象和发生背景
问题遇到的现象和发生背景

这个为什么一直部署错误的,大概是哪里的问题的,应该怎么解决的啊,这个是不是因为存在的多个上下文
而且还直接找不到类了,报错显示的找不到,就找不到哪里出的问题

web.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
         version="4.0">

    <context-param>
   
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:spring-persist-*.xml</param-value>
    </context-param>
    <listener>
        
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <!--字符码过滤器-->
    <filter>
        <filter-name>CharacterEncodingFilter</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        <!--字符集设置-->
        <init-param>
            <param-name>encoding</param-name>
            <param-value>utf-8</param-value>
        </init-param>
        <!--强制设置请求字符-->
        <init-param>
            <param-name>forceRequestEncoding</param-name>
            <param-value>true</param-value>
        </init-param>
        <!--强制设置响应字符-->
        <init-param>
            <param-name>forceResponseEncoding</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>CharacterEncodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>


    <!--restful风格-->
    <filter>
        <filter-name>HiddenHttpMethodFilter</filter-name>
        <filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>HiddenHttpMethodFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <servlet>
        <servlet-name>DispatcherServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>DispatcherServlet</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>
</web-app>

spring-persist-mybatis.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation=
               "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
               http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">



    <!--加载外部属性文件-->
    <context:property-placeholder location="classpath:jdbc.properties"/>
    <!--配置数据源-->
    <bean id="dataSourcee" class="com.alibaba.druid.pool.DruidDataSource">
        <property name="username" value="${jdbc.username}"/>
        <property name="password" value="${jdbc.password}"/>
        <property name="url" value="${jdbc.url}"/>
        <property name="driverClassName" value="${jdbc.driver}"/>
    </bean>

    <!--配置SqlSessionFactoryBean整合Mybatis-->
    <bean id="SqlSessionFactoryBean" class="org.mybatis.spring.SqlSessionFactoryBean">
      <!--装配数据源-->
        <property name="dataSource" ref="dataSourcee"/>
        <!--指定mybatis配置文件的位置-->
        <property name="configLocation" value="classpath:mybatis-config.xml"/>
       <!--指定Mapper文件的位置-->
        <property name="mapperLocations" value="classpath:mybatis/mapper/*Mapper.xml"/>
    </bean>


    <!--指定Mapper接口所在的包-->
    <bean id="MapperScannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="com.atguigu.crowd.mapper"></property>
    </bean>


spring-persist-tx.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xsi:schemaLocation="
            http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
            http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
            http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">

    <!--配置自动扫描,将Service加入到IOC容器中-->
    <context:component-scan base-package="com.atguigu.crowd.Service"/>

    <!--给Service配置事务管理-->
    <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <!--装配数据源-->
        <property name="dataSource" ref="dataSourcee"/>
    </bean>
    <tx:annotation-driven transaction-manager="txManager"/>
    <!-- 配置 AOP -->
    <aop:config>
        <!-- 配置切入点表达式 -->
        <!-- public String com.atguigu.crowd.service.AdminService.getXxx(Integer id) -->
        <aop:pointcut expression="execution(* *..*ServiceImpl.*(..))" id="txPointCut"/>
        <!-- 将事务通知和切入点表达式关联到一起 -->
        <aop:advisor advice-ref="txAdvice" pointcut-ref="txPointCut"/>
    </aop:config>
    <!-- 配置事务通知 -->
    <!-- id 属性用于在 aop:advisor 中引用事务通知 -->
    <!-- transaction-manager 属性用于引用事务管理器,如果事务管理器的 bean 的 id 正好是
    transactionManager,可以省略这个属性 -->
    <tx:advice id="txAdvice" transaction-manager="txManager">
    <tx:attributes>
    <!-- name 属性指定当前要配置的事务方法的方法名 -->
    <!-- 查询的方法通常设置为只读,便于数据库根据只读属性进行相关性能优化 -->
    <tx:method name="get*" read-only="true"/>
    <tx:method name="query*" read-only="true"/>
    <tx:method name="find*" read-only="true"/>
    <tx:method name="count*" read-only="true"/>
     
        <tx:method name="save*" propagation="REQUIRES_NEW"
                   rollback-for="java.lang.Exception" />
        <tx:method name="remove*" propagation="REQUIRES_NEW"
                   rollback-for="java.lang.Exception" />
        <tx:method name="update*" propagation="REQUIRES_NEW"
                   rollback-for="java.lang.Exception" />
    </tx:attributes>
    </tx:advice>


</beans>

spring-web-mvc.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

    <!--扫描的包-->
    <context:component-scan base-package="com.atguigu.crowd.mvc.handler"/>
    <!--开启注解扫描-->
    <mvc:annotation-driven/>

    <bean id="InternalResourceViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/"/>
        <property name="suffix" value=".html"/>
    </bean>
</beans>

  • 写回答

1条回答 默认 最新

  • 薄荷味脑花 2022-03-26 19:02
    关注

    这种情况可能性较多,有可能是版本冲突导致某个包的类识别不了,你看哈找不到的那个类可能在的包是哪个,换个版本号试试

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 3月27日
  • 已采纳回答 3月27日
  • 创建了问题 3月26日

悬赏问题

  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办