1.web.xml文件配置
- <?xml version="1.0" encoding="UTF-8"?>
- <web-app version="2.5"
- xmlns="http://java.sun.com/xml/ns/javaee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
- http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
- <welcome-file-list>
- <welcome-file>index.jsp</welcome-file>
- </welcome-file-list>
- <!-- spring文件的加载 -->
- <context-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>classpath:/spring.xml</param-value>
- </context-param>
- <listener>
- <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
- </listener>
- <!-- struts2文件加载 -->
- <filter>
- <filter-name>struts2</filter-name>
- <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
- </filter>
- <filter-mapping>
- <filter-name>struts2</filter-name>
- <url-pattern>*.do</url-pattern>
- </filter-mapping>
- <filter-mapping>
- <filter-name>struts2</filter-name>
- <url-pattern>*.jsp</url-pattern>
- </filter-mapping>
- <filter>
- <filter-name>encodingFilter</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>forceEncoding</param-name>
- <param-value>true</param-value>
- </init-param>
- </filter>
- <filter-mapping>
- <filter-name>encodingFilter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
- </web-app>
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <!-- spring文件的加载 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:/spring.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- struts2文件加载 --> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>*.do</url-pattern> </filter-mapping> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>*.jsp</url-pattern> </filter-mapping> <filter> <filter-name>encodingFilter</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>forceEncoding</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app>
2.spring.xml文件配置也就是spring的核心配置文件
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="<a href="http://www.springframework.org/schema/beans">http://www.springframework.org/schema/beans</a>"
- xmlns:xsi="<a href="http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001/XMLSchema-instance</a>"
- xmlns:tx="<a href="http://www.springframework.org/schema/tx">http://www.springframework.org/schema/tx</a>"
- xmlns:aop="<a href="http://www.springframework.org/schema/aop">http://www.springframework.org/schema/aop</a>"
- xsi:schemaLocation="<a href="http://www.springframework.org/schema/beans">http://www.springframework.org/schema/beans</a> <a href="http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">http://www.springframework.org/schema/beans/spring-beans-2.5.xsd</a>
- <a href="http://www.springframework.org/schema/tx">http://www.springframework.org/schema/tx</a> <a href="http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">http://www.springframework.org/schema/tx/spring-tx-2.5.xsd</a>
- <a href="http://www.springframework.org/schema/aop">http://www.springframework.org/schema/aop</a> <a href="http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">http://www.springframework.org/schema/aop/spring-aop-2.5.xsd</a>">
- <bean id="sessionFactory"
- class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
- <property name="configLocation"
- value="classpath:hibernate.cfg.xml">
- </property>
- </bean>
- <!--调用service的接口的方法让他定时执行,必须的文件 -->
- <bean class="com.guoxin.util.MyApplicationContextUtil"></bean>
- <import resource="spring_BlockAction.xml"/>
- <import resource="spring_BlockDao.xml"/>
- <import resource="spring_BlockService.xml"/>
- <import resource="scheduler.xml"/>
- </beans>
<?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:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd"> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="configLocation" value="classpath:hibernate.cfg.xml"> </property> </bean> <!--调用service的接口的方法让他定时执行,必须的文件 --> <bean class="com.guoxin.util.MyApplicationContextUtil"></bean> <import resource="spring_BlockAction.xml"/> <import resource="spring_BlockDao.xml"/> <import resource="spring_BlockService.xml"/> <import resource="scheduler.xml"/> </beans>
3.spring_BlockAction.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:jaxws="http://cxf.apache.org/jaxws"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
- <bean id="blockAction"class="com.guoxin.action.BlockAction">
- <property name="blockservice">
- <ref bean="blockService"/>
- </property>
- </bean>
- </beans>
<?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:jaxws="http://cxf.apache.org/jaxws" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> <bean id="blockAction" class="com.guoxin.action.BlockAction"> <property name="blockservice"> <ref bean="blockService"/> </property> </bean> </beans>
4.spring_BlockDao.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"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
- <bean id="blockDao"class="com.guoxin.dao.GetBlockUrlImp">
- <property name="sessionFactory">
- <ref bean="sessionFactory"/>
- </property>
- </bean>
- </beans>
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> <bean id="blockDao" class="com.guoxin.dao.GetBlockUrlImp"> <property name="sessionFactory"> <ref bean="sessionFactory"/> </property> </bean> </beans>
5.spring_BlockService.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:jaxws="http://cxf.apache.org/jaxws"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
- <bean id="blockService"class="com.guoxin.service.GetBlockUrlServiceImp">
- <property name="blockdao">
- <ref bean="blockDao"/>
- </property>
- </bean>
- </beans>
<?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:jaxws="http://cxf.apache.org/jaxws" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> <bean id="blockService" class="com.guoxin.service.GetBlockUrlServiceImp"> <property name="blockdao"> <ref bean="blockDao"/> </property> </bean> </beans>
6.struts.xml文件配置
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE struts PUBLIC
- "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
- "http://struts.apache.org/dtds/struts-2.0.dtd">
- <struts>
- <include file="Block.xml"></include>
- </struts>
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <include file="Block.xml"></include> </struts>
7.Block.xml文件配置
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE struts PUBLIC
- "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
- "http://struts.apache.org/dtds/struts-2.0.dtd">
- <struts>
- <constant name="struts.i18n.encoding" value="UTF-8" />
- <package name="default"extends="struts-default">
- <action name="blockaction"class="blockAction" method="test">
- <result name="success">/MyJsp2.jsp</result>
- </action>
- </package>
- </struts>
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <constant name="struts.i18n.encoding" value="UTF-8" /> <package name="default" extends="struts-default"> <action name="blockaction" class="blockAction" method="test"> <result name="success">/MyJsp2.jsp</result> </action> </package> </struts>
8.主要代码
- package com.guoxin.util;
- import org.springframework.beans.BeansException;
- import org.springframework.context.ApplicationContext;
- import org.springframework.context.ApplicationContextAware;
- publicclass MyApplicationContextUtil implements ApplicationContextAware {
- privatestatic ApplicationContext context;
- // 声明一个静态变量保存
- publicvoid setApplicationContext(ApplicationContext contex) throws BeansException {
- context = contex;
- }
- publicstatic ApplicationContext getContext() {
- return context;
- }
- }
package com.guoxin.util; import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; public class MyApplicationContextUtil implements ApplicationContextAware { private static ApplicationContext context; // 声明一个静态变量保存 public void setApplicationContext(ApplicationContext contex) throws BeansException { context = contex; } public static ApplicationContext getContext() { return context; } }
- package com.guoxin.util;
- import java.util.List;
- import org.quartz.JobExecutionContext;
- import org.quartz.JobExecutionException;
- import org.springframework.scheduling.quartz.QuartzJobBean;
- import com.guoxin.bean.Block;
- import com.guoxin.service.Iservice.GetBlockUrlService;
- import com.rabbitmq.client.Channel;
- import com.rabbitmq.client.Connection;
- import com.rabbitmq.client.ConnectionFactory;
- import com.rabbitmq.client.MessageProperties;
- import com.sun.codemodel.JNullType;
- @SuppressWarnings("deprecation")
- publicclass DMSMethod extends QuartzJobBean{
- private GetBlockUrlService blockservice;//调用service层的接口
- public DMSMethod(){
- blockservice = (GetBlockUrlService)MyApplicationContextUtil.getContext().getBean("blockService");
- }
- protectedvoid executeInternal(JobExecutionContext arg0)
- throws JobExecutionException {
- try {
- //获得静态版块的链接
- List<Block> staticList=blockservice.queryBlockUrlStatic();
- for(Block block:staticList){
- String task=block.getBlock_url();
- System.out.println("静态:"+task);
- }
- } catch (Exception e) {
- // TODO: handle exception
- e.printStackTrace();
- }
- System.out.println("执行..........");
- }
- public GetBlockUrlService getBlockservice() {
- return blockservice;
- }
- }
package com.guoxin.util; import java.util.List; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; import org.springframework.scheduling.quartz.QuartzJobBean; import com.guoxin.bean.Block; import com.guoxin.service.Iservice.GetBlockUrlService; import com.rabbitmq.client.Channel; import com.rabbitmq.client.Connection; import com.rabbitmq.client.ConnectionFactory; import com.rabbitmq.client.MessageProperties; import com.sun.codemodel.JNullType; @SuppressWarnings("deprecation") public class DMSMethod extends QuartzJobBean{ private GetBlockUrlService blockservice;//调用service层的接口 public DMSMethod(){ blockservice = (GetBlockUrlService)MyApplicationContextUtil.getContext().getBean("blockService"); } protected void executeInternal(JobExecutionContext arg0) throws JobExecutionException { try { //获得静态版块的链接 List<Block> staticList=blockservice.queryBlockUrlStatic(); for(Block block:staticList){ String task=block.getBlock_url(); System.out.println("静态:"+task); } } catch (Exception e) { // TODO: handle exception e.printStackTrace(); } System.out.println("执行.........."); } public GetBlockUrlService getBlockservice() { return blockservice; } }
- package com.guoxin.service;
- import java.util.List;
- import com.guoxin.bean.Block;
- import com.guoxin.dao.Idao.GetBlockUrl;
- import com.guoxin.service.Iservice.GetBlockUrlService;
- publicclass GetBlockUrlServiceImp implements GetBlockUrlService {
- private GetBlockUrl blockdao;
- public List<Block> queryBlockUrlStatic() {
- List<Block> list=blockdao.queryBlockUrlStatic();
- return list;
- }
- public List<Block> queryBlockUrlTrends() {
- List<Block> list=blockdao.queryBlockUrlStatic();
- return list;
- }
- public GetBlockUrl getBlockdao() {
- return blockdao;
- }
- publicvoid setBlockdao(GetBlockUrl blockdao) {
- this.blockdao = blockdao;
- }
- }
相关推荐
Java开发案例-springboot-06-整合RabbitMQ-源代码+文档.rar Java开发案例-springboot-06-整合RabbitMQ-源代码+文档.rar Java开发案例-springboot-06-整合RabbitMQ-源代码+文档.rar Java开发案例-springboot-06-整合...
spring.rabbitmq.host=your-rabbitmq-host spring.rabbitmq.port=your-rabbitmq-port spring.rabbitmq.username=your-username spring.rabbitmq.password=your-password ``` 或者使用YAML格式: ```yaml # ...
rabbitmq-server-3.11.13rabbitmq-server-3.11.13rabbitmq-server-3.11.13rabbitmq-server-3.11.13rabbitmq-server-3.11.13rabbitmq-server-3.11.13rabbitmq-server-3.11.13rabbitmq-server-3.11.13rabbitmq-server-...
1. **获取源码**:首先,从官方仓库或者提供的压缩包中下载`rabbitmq-c-master`源代码。 2. **创建构建目录**:为了保持源代码的整洁,我们通常在源代码目录外创建一个新目录,例如`build`,用于放置编译生成的文件...
1. **配置依赖**:在项目的`pom.xml`文件中添加RabbitMQ的Spring整合依赖。如: ```xml <groupId>org.springframework.amqp <artifactId>spring-rabbit <version>2.3.7 ``` 确保版本号与你的Spring框架版本兼容...
rpm -ivh rabbitmq-server-3.6.5-1.noarch.rpm systemctl status rabbitmq-server systemctl start rabbitmq-server systemctl stop rabbitmq-server systemctl restart rabbitmq-server systemctl enable ...
**RabbitMQ-c源码分析** RabbitMQ-c是一个轻量级且高效的C语言实现的RabbitMQ客户端库。RabbitMQ是一个开源的消息代理和队列服务器,它使用AMQP(Advanced Message Queuing Protocol)协议,广泛应用于分布式系统中...
在安装了RabbitMQ的服务器上执行`rabbitmq-plugins enable rabbitmq_management`命令即可启用。接着,需要创建一个用户,例如`user_admin`,并设置相应的权限,以便登录管理控制台。 一旦登录Web控制台,最需要注意...
rabbitmq spring rabbitmq spring rabbitmq spring rabbitmq spring http://knight-black-bob.iteye.com/blog/2304089
1. **下载**:首先,你需要从官方网站下载适合你的Linux发行版的RabbitMQ版本,如"rabbitmq-server-generic-unix-3.5.4.tar.gz"。你可以使用wget命令或者直接在浏览器中下载。 2. **解压**:使用tar命令解压下载的...
这里提供了rabbitmq-server-3.7.3.exe百度网盘下载,官网下载实在是太慢了,亲测有效! rabbitmq-server-3.7.3.exe rabbitmq-server-3.7.3.exe rabbitmq-server-3.7.3.exe
在“spring-cloud-steam-rabbitmq-demo”项目中,我们将了解以下几个关键知识点: 1. **配置Spring Cloud Stream**: 首先,我们需要在`application.yml`或`application.properties`中配置RabbitMQ的相关信息,...
94-springcloud的rabbitmq的publisher消息发送者、rabbitmq消息中间件、receive
标题中的“rabbitmq-server-generic-unix-3.6.1.tar”是指RabbitMQ服务器的3.6.1版本的通用Unix安装包。RabbitMQ是一个开源的消息代理和队列服务器,广泛应用于分布式系统中,用于处理异步任务、消息传递和负载均衡...
rpm -ivh rabbitmq-server-4.0.2-1.el8.noarch.rpm systemctl status rabbitmq-server systemctl start rabbitmq-server systemctl stop rabbitmq-server systemctl restart rabbitmq-server systemctl enable ...
rabbitmq-spring-topic-exchange rabbitmq主题示例 rabbitmq-java-rpc rabbitmq PRC通信示例 rabbitmq-spring-helloworld spring boot 使用rabbitmq的第一个demo rabbitmq-spring-work-queue spring boot使用...
【课程目录】:---第一章:RabbitMQ介绍----1-什么是消息中间件.mp4----2-RabbitMQ消息队列安装:window环境.mp4----3-RabbitMQ消息队列安装 :Linux环境.mp4----4-Rabbitmq入口示例:server.mp4----5-rabbitmq入口...
rabbitmq-server-3.6.1 的安装程序,rabbitmq-server-3.6.1 安装 rabbitmq-server
2. **安装与配置**:`rabbitmq-server-3.8.5.exe`是RabbitMQ Windows版的安装程序,用户可以通过这个可执行文件进行安装。安装过程中会涉及服务启动设置、端口配置(默认5672用于AMQP,15672用于管理界面)、环境...
docker-compose部署单机rabbitmq,一键启动