spring注解配置文件解析

本文详细介绍了Spring框架下三个核心配置文件的应用:applicationContext.xml用于数据访问配置,包括数据源、事务管理和注解支持等;fipmis-servlet.xml负责Web层配置,如视图解析、文件上传和拦截器设置等;config.xml则是存放数据库连接和其他系统级参数的配置文件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、applicationContext.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:tx="http://www.springframework.org/schema/tx"
 xmlns:context="http://www.springframework.org/schema/context"
 
 xsi:schemaLocation="http://www.springframework.org/schema/beans  http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
   http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
   http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

    <description>数据访问的配置文件</description>
   
    
     <!-- 导入配置文件 -->
    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>classpath:config.xml</value>
            </list>
        </property>
    </bean>
   
    <!-- 激活在bean中定义的各种注解,@Transactional注解除外,它需要tx:annotation-driven激活 -->
    <context:annotation-config/>
   
 <!-- 使用annotation 自动注册bean,并保证@Required,@Autowired的属性被注入 -->
 <context:component-scan base-package="com.ztev.fipmis" />
    <context:component-scan base-package="com.ztev.webapp" />
    
    <!-- 数据源配置 -->
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
      <property name="driverClassName" value="${jdbc.driverClassName}"/>
        <property name="url" value="${jdbc.url}"/>
        <property name="username" value="${jdbc.username}"/>
        <property name="password" value="${jdbc.password}"/>
        <!-- 以下设置解决connection reset问题 -->
        <property name="testOnBorrow" value="true" />
  <property name="testWhileIdle" value="true" />
  <property name="validationQuery" value="select 1" />
    </bean>
   
    <!-- 分页实例 -->
    <bean id="pagination" class="com.ztev.pagination.impl.PageSqlServer">
     <property name="dataSource" ref="dataSource"/>
    </bean>
  
   
    <!-- 数据库的事务管理器配置 -->
 <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  <property name="dataSource" ref="dataSource" />
 </bean>

 <!-- 使用annotation定义数据库事务,这样可以在类或方法中直接使用@Transactional注解来声明事务 -->
 <tx:annotation-driven transaction-manager="transactionManager" />

</beans>

 

 

 

2、fipmis-servlet.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:p="http://www.springframework.org/schema/p"
 xmlns:context="http://www.springframework.org/schema/context"

 xsi:schemaLocation="http://www.springframework.org/schema/beans  http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
 http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">

 <description>与web相关的配置</description>

 <!-- 显示层采用JSTL -->
 <bean id="viewResolver"
  class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  <property name="viewClass"
   value="org.springframework.web.servlet.view.JstlView" />
  <property name="prefix" value="/pages/" />
  <property name="suffix" value=".jsp" />
 </bean>

 <!--
  启动Spring MVC的注解功能,完成请求和注解POJO的映射,也可由<context:annotation-config/>启动
  <bean
  class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>
 -->
 <bean id="multipartResolver"
  class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
  <property name="maxUploadSize" value="30000000" />
 </bean>

 <!-- 登陆拦截器 -->
 <bean id="loginInterceptor" class="com.ztev.webapp.LoginInterceptor">
  <property name="loginView" value="/index.jsp"/>
 </bean>
 
 <bean id="urlMappingManualLogin" autowire="no"
  class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
  <property name="interceptors">
   <list>
    <ref bean="loginInterceptor" />
   </list>
  </property>
 </bean>
 
</beans>

 

 

 

3、config.xml

 

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
 
 <comment>系统配置</comment>
 
 <!-- 数据库相关配置  ====================================================================================== -->
 
 <!-- 数据库配置 -->
 <entry key="jdbc.driverClassName">net.sourceforge.jtds.jdbc.Driver</entry>
 <entry key="jdbc.url">jdbc:jtds:sqlserver://127.0.0.1:1433/fipmis;charset=gbk</entry>
 <entry key="jdbc.username">sa</entry>
 <entry key="jdbc.password">123456</entry>
 
 <!-- 地图服务相关的配置 -->
 <entry key="map.server.host">127.0.0.1</entry><!-- 地图主机地址,如果为空则视为和web服务在同一台服务器上 -->
 <entry key="map.server.port"></entry><!-- 地图服务端口,如果为空则视为web默认端口,即80 -->
 <entry key="map.server.path">fipmismap</entry><!-- 地图服务路径,即IIS中发布的虚拟目录名称 -->
 
 
 <!-- 上传目录及权限限制 -->
 <entry key="file.base.uri">/uploads/file</entry>
 <entry key="files.denied">jsp,vm,cgi,dll,asp,php,aspx,pl,exe</entry>
</properties>

资源下载链接为: https://pan.quark.cn/s/140386800631 通用大模型文本分类实践的基本原理是,借助大模型自身较强的理解和推理能力,在使用时需在prompt中明确分类任务目标,并详细解释每个类目概念,尤其要突出类目间的差别。 结合in-context learning思想,有效的prompt应包含分类任务介绍及细节、类目概念解释、每个类目对应的例子和待分类文本。但实际应用中,类目和样本较多易导致prompt过长,影响大模型推理效果,因此可先通过向量检索缩小范围,再由大模型做最终决策。 具体方案为:离线时提前配置好每个类目的概念及对应样本;在线时先对给定query进行向量召回,再将召回结果交给大模型决策。 该方法不更新任何模型参数,直接使用开源模型参数。其架构参考GPT-RE并结合相关实践改写,加入上下文学习以提高准确度,还使用BGE作为向量模型,K-BERT提取文本关键词,拼接召回的相似例子作为上下文输入大模型。 代码实现上,大模型用Qwen2-7B-Instruct,Embedding采用bge-base-zh-v1.5,向量库选择milvus。分类主函数的作用是在向量库中召回相似案例,拼接prompt后输入大模型。 结果方面,使用ICL时accuracy达0.94,比bert文本分类的0.98低0.04,错误类别6个,处理时添加“家居”类别,影响不大;不使用ICL时accuracy为0.88,错误58项,可能与未修改prompt有关。 优点是无需训练即可有较好结果,例子优质、类目界限清晰时效果更佳,适合围绕通用大模型api打造工具;缺点是上限不高,仅针对一个分类任务部署大模型不划算,推理速度慢,icl的token使用多,用收费api会有额外开销。 后续可优化的点是利用key-bert提取的关键词,因为核心词语有时比语意更重要。 参考资料包括
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值