当前位置: 首页 > news >正文

在国外做盗版电影网站吗无锡网站优化推广

在国外做盗版电影网站吗,无锡网站优化推广,企业邮箱注册申请,营销策划公司介绍一、Zookeeper实现分布式锁 分布式锁主要用于在分布式环境中保证数据的一致性。 包括跨进程、跨机器、跨网络导致共享资源不一致的问题。 1. 分布式锁的实现思路 说明#xff1a; 这种实现会有一个缺点#xff0c;即当有很多进程在等待锁的时候#xff0c;在释放锁的时候会有…一、Zookeeper实现分布式锁 分布式锁主要用于在分布式环境中保证数据的一致性。 包括跨进程、跨机器、跨网络导致共享资源不一致的问题。 1. 分布式锁的实现思路 说明 这种实现会有一个缺点即当有很多进程在等待锁的时候在释放锁的时候会有很多进程就过来争夺锁这种现象称为 “惊群效应” 2. 分布式锁优化后的实现思路   3. Zookeeper分布式锁的代码实现 准备工作 1安装Zookeeper具体参考我前面的我文章Zookeeper系列一Zookeeper介绍、Zookeeper安装配置、ZK Shell的使用 2新建一个maven项目ZK-Demo,然后在pom.xml里面引入相关的依赖 dependencygroupIdcom.101tec/groupIdartifactIdzkclient/artifactIdversion0.10/version/dependency 3.1 Zookeeper分布式锁的核心代码实现 实现逻辑参考“2. 分布式锁优化后的实现思路”中的流程图 package com.study.demo.lock;import java.util.Collections; import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.Lock;import org.I0Itec.zkclient.IZkDataListener; import org.I0Itec.zkclient.ZkClient; import org.I0Itec.zkclient.serialize.SerializableSerializer; import org.slf4j.Logger; import org.slf4j.LoggerFactory;/** * * Description: Zookeeper分布式锁的核心代码实现 * author leeSmall * date 2018年9月4日 * */ public class DistributedLock implements Lock {private static Logger logger LoggerFactory.getLogger(DistributedLock.class);private static final String ZOOKEEPER_IP_PORT 192.168.152.130:2181;private static final String LOCK_PATH /LOCK;private ZkClient client new ZkClient(ZOOKEEPER_IP_PORT, 4000, 4000, new SerializableSerializer());private CountDownLatch cdl;private String beforePath;// 当前请求的节点前一个节点private String currentPath;// 当前请求的节点// 判断有没有LOCK目录没有则创建public DistributedLock() {if (!this.client.exists(LOCK_PATH)) {this.client.createPersistent(LOCK_PATH);}}public void lock() {//尝试去获取分布式锁失败if (!tryLock()) {//对次小节点进行监听waitForLock();lock();} else {logger.info(Thread.currentThread().getName() 获得分布式锁);}}public boolean tryLock() {// 如果currentPath为空则为第一次尝试加锁第一次加锁赋值currentPathif (currentPath null || currentPath.length() 0) {// 创建一个临时顺序节点currentPath this.client.createEphemeralSequential(LOCK_PATH /, lock);System.out.println(---------------------------- currentPath);}// 获取所有临时节点并排序临时节点名称为自增长的字符串如0000000400ListString childrens this.client.getChildren(LOCK_PATH);//由小到大排序所有子节点Collections.sort(childrens);//判断创建的子节点/LOCK/Node-n是否最小,即currentPath,如果当前节点等于childrens中的最小的一个就占用锁if (currentPath.equals(LOCK_PATH / childrens.get(0))) {return true;} //找出比创建的临时顺序节子节点/LOCK/Node-n次小的节点,并赋值给beforePathelse {int wz Collections.binarySearch(childrens, currentPath.substring(6));beforePath LOCK_PATH / childrens.get(wz - 1);}return false;}//等待锁,对次小节点进行监听private void waitForLock() {IZkDataListener listener new IZkDataListener() {public void handleDataDeleted(String dataPath) throws Exception {logger.info(Thread.currentThread().getName() :捕获到DataDelete事件---------------------------);if (cdl ! null) {cdl.countDown();}}public void handleDataChange(String dataPath, Object data) throws Exception {}};// 对次小节点进行监听,即beforePath-给排在前面的的节点增加数据删除的watcherthis.client.subscribeDataChanges(beforePath, listener);if (this.client.exists(beforePath)) {cdl new CountDownLatch(1);try {cdl.await();} catch (InterruptedException e) {e.printStackTrace();}}this.client.unsubscribeDataChanges(beforePath, listener);}//完成业务逻辑以后释放锁public void unlock() {// 删除当前临时节点client.delete(currentPath);}// public void lockInterruptibly() throws InterruptedException {}public boolean tryLock(long time, TimeUnit unit) throws InterruptedException {return false;}public Condition newCondition() {return null;} }  3.2 在业务里面使用分布式锁 package com.study.demo.lock;import java.util.concurrent.CountDownLatch; import java.util.concurrent.locks.Lock;import org.slf4j.Logger; import org.slf4j.LoggerFactory;/** * * Description: 在业务里面使用分布式锁 * author leeSmall * date 2018年9月4日 * */ public class OrderServiceImpl implements Runnable {private static OrderCodeGenerator ong new OrderCodeGenerator();private Logger logger LoggerFactory.getLogger(OrderServiceImpl.class);// 同时并发的线程数private static final int NUM 10;// 按照线程数初始化倒计数器,倒计数器private static CountDownLatch cdl new CountDownLatch(NUM);private Lock lock new DistributedLock();// 创建订单接口public void createOrder() {String orderCode null;//准备获取锁lock.lock();try {// 获取订单编号orderCode ong.getOrderCode();} catch (Exception e) {// TODO: handle exception} finally {//完成业务逻辑以后释放锁lock.unlock();}// ……业务代码 logger.info(insert into DB使用id orderCode);}public void run() {try {// 等待其他线程初始化cdl.await();} catch (InterruptedException e) {// TODO Auto-generated catch blocke.printStackTrace();}// 创建订单createOrder();}public static void main(String[] args) {for (int i 1; i NUM; i) {// 按照线程数迭代实例化线程new Thread(new OrderServiceImpl()).start();// 创建一个线程倒计数器减1cdl.countDown();}} } 工具类 package com.study.demo.lock;import java.text.SimpleDateFormat; import java.util.Date;public class OrderCodeGenerator {// 自增长序列private static int i 0;// 按照“年-月-日-小时-分钟-秒-自增长序列”的规则生成订单编号public String getOrderCode() {Date now new Date();SimpleDateFormat sdf new SimpleDateFormat(yyyyMMddHHmmss);return sdf.format(now) i;}} 二、Zookeeper实现配置中心  1. 首先在zookeeper里面创建一个Jdbc的节点在下面分别创建4个子节点/Jdbc/url、/Jdbc/uname、/Jdbc/password、/Jdbc/driver create /Jdbc create /Jdbc/url jdbc.mysql://192.168.152.1/dbspread create /Jdbc/uname root create /Jdbc/password 123456 create /Jdbc/driver com.mysql.jdbc.Driver 注意/Jdbc/url这个节点的值是错的       2. 新建一个zkdemo的maven的web项目 项目结构如下 2.1 在pom.xml文件里面引入下面依赖 project xmlnshttp://maven.apache.org/POM/4.0.0 xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsdmodelVersion4.0.0/modelVersiongroupIdcom.study.demo/groupIdartifactIdzkdemo/artifactIdpackagingwar/packagingversion0.0.1-SNAPSHOT/versionnamezkdemo Maven Webapp/nameurlhttp://maven.apache.org/urlpropertiesspring.version4.3.8.RELEASE/spring.version/propertiesdependenciesdependencygroupIdjunit/groupIdartifactIdjunit/artifactIdversion3.8.1/versionscopetest/scope/dependencydependencygroupIdorg.apache.zookeeper/groupIdartifactIdzookeeper/artifactIdversion3.4.10/version/dependencydependencygroupIdcom.101tec/groupIdartifactIdzkclient/artifactIdversion0.10/version/dependencydependencygroupIdorg.apache.curator/groupIdartifactIdcurator-framework/artifactIdversion4.0.0/version/dependencydependencygroupIdorg.apache.curator/groupIdartifactIdcurator-recipes/artifactIdversion4.0.0/version/dependencydependencygroupIdjavax.servlet/groupIdartifactIdjavax.servlet-api/artifactIdversion3.1.0/version/dependencydependencygroupIdorg.apache.tomcat/groupIdartifactIdtomcat-catalina/artifactIdversion7.0.39/version/dependencydependencygroupIdorg.springframework/groupIdartifactIdspring-core/artifactIdversion${spring.version}/version/dependencydependencygroupIdorg.springframework/groupIdartifactIdspring-beans/artifactIdversion${spring.version}/version/dependencydependencygroupIdorg.springframework/groupIdartifactIdspring-jdbc/artifactIdversion${spring.version}/version/dependencydependencygroupIdorg.springframework/groupIdartifactIdspring-context/artifactIdversion${spring.version}/version/dependencydependencygroupIdorg.springframework/groupIdartifactIdspring-web/artifactIdversion${spring.version}/version/dependencydependencygroupIdorg.springframework/groupIdartifactIdspring-webmvc/artifactIdversion${spring.version}/version/dependencydependencygroupIdcom.zaxxer/groupIdartifactIdHikariCP/artifactIdversion2.7.1/version/dependencydependencygroupIdmysql/groupIdartifactIdmysql-connector-java/artifactIdversion5.1.41/version/dependencydependencygroupIdorg.slf4j/groupIdartifactIdslf4j-api/artifactIdversion1.7.25/version/dependencydependencygroupIdorg.slf4j/groupIdartifactIdjcl-over-slf4j/artifactIdversion1.7.25/version/dependencydependencygroupIdlog4j/groupIdartifactIdlog4j/artifactIdversion1.2.17/version/dependencydependencygroupIdcom.fasterxml.jackson.core/groupIdartifactIdjackson-core/artifactIdversion2.9.1/version/dependencydependencygroupIdcom.fasterxml.jackson.core/groupIdartifactIdjackson-databind/artifactIdversion2.9.1/version/dependencydependencygroupIdjavax.servlet/groupIdartifactIdjstl/artifactIdversion1.2/version/dependency/dependenciesbuildfinalNamezkdemo/finalName/build /project 2.2 新建一个zookeeper配置中心类,从zookeeper动态获取数据库配置 package com.study.demo.config;import java.util.List; import java.util.Properties;import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.CuratorFrameworkFactory; import org.apache.curator.framework.recipes.cache.TreeCache; import org.apache.curator.framework.recipes.cache.TreeCacheEvent; import org.apache.curator.framework.recipes.cache.TreeCacheListener; import org.apache.curator.retry.ExponentialBackoffRetry; import org.springframework.web.context.ContextLoader; import org.springframework.web.context.WebApplicationContext;import com.zaxxer.hikari.HikariDataSource;/** * * Description: zookeeper配置中心类,从zookeeper动态获取数据库配置 * author leeSmall * date 2018年9月10日 * */ public class ZookeeperConfigurerCentral {//curator客户端private CuratorFramework zkClient;//curator事件监听private TreeCache treeCache;//zookeeper的ip和端口private String zkServers;//zookeeper上的/Jdbc路径private String zkPath;//超时设置private int sessionTimeout;//读取zookeeper上的数据库配置文件放到这里private Properties props;public ZookeeperConfigurerCentral(String zkServers, String zkPath, int sessionTimeout) {this.zkServers zkServers;this.zkPath zkPath;this.sessionTimeout sessionTimeout;this.props new Properties();//初始化curator客户端initZkClient();//从zookeeper的Jdbc节点下获取数据库配置存入propsgetConfigData();//对zookeeper上的数据库配置文件所在节点进行监听如果有改变就动态刷新propsaddZkListener();}//初始化curator客户端private void initZkClient() {zkClient CuratorFrameworkFactory.builder().connectString(zkServers).sessionTimeoutMs(sessionTimeout).retryPolicy(new ExponentialBackoffRetry(1000, 3)).build();zkClient.start();}//从zookeeper的Jdbc节点下获取数据库配置存入propsprivate void getConfigData() {try {ListString list zkClient.getChildren().forPath(zkPath);for (String key : list) {String value new String(zkClient.getData().forPath(zkPath / key));if (value ! null value.length() 0) {props.put(key, value);}}} catch (Exception e) {e.printStackTrace();}}//对zookeeper上的数据库配置文件所在节点进行监听如果有改变就动态刷新propsprivate void addZkListener() {TreeCacheListener listener new TreeCacheListener() {public void childEvent(CuratorFramework client, TreeCacheEvent event) throws Exception {if (event.getType() TreeCacheEvent.Type.NODE_UPDATED) {getConfigData();WebApplicationContext ctx ContextLoader.getCurrentWebApplicationContext();HikariDataSource dataSource (HikariDataSource) ctx.getBean(dataSource);System.out.println(props.getProperty(url));dataSource.setJdbcUrl(props.getProperty(url));dataSource.setUsername(props.getProperty(uname));dataSource.setPassword(props.getProperty(password ));dataSource.setDriverClassName(props.getProperty(driver ));}}};treeCache new TreeCache(zkClient, zkPath);try {treeCache.start();treeCache.getListenable().addListener(listener);} catch (Exception e) {e.printStackTrace();}}public Properties getProps() {return props;}public void setZkServers(String zkServers) {this.zkServers zkServers;}public void setZkPath(String zkPath) {this.zkPath zkPath;}public void setSessionTimeout(int sessionTimeout) {this.sessionTimeout sessionTimeout;} } 2.3 新建一个加载props里面的数据库配置的类 package com.study.demo.config;import java.util.Properties;import org.springframework.beans.BeansException; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;/** * * Description: 加载props里面的数据库配置,这个类等价于以前在xml文件里面的配置 * context:property-placeholder locationclasspath:config/jdbc_conf.properties/ * author leeSmall * date 2018年9月10日 * */ public class ZookeeperPlaceholderConfigurer extends PropertyPlaceholderConfigurer {private ZookeeperConfigurerCentral zkConfigurerCentral;Overrideprotected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess, Properties props)throws BeansException {System.out.println(zkConfigurerCentral.getProps());super.processProperties(beanFactoryToProcess, zkConfigurerCentral.getProps());}public void setzkConfigurerCentral(ZookeeperConfigurerCentral zkConfigurerCentral) {this.zkConfigurerCentral zkConfigurerCentral;} } 2.4 在/zkdemo/src/main/webapp/WEB-INF/config/applicationContext.xml配置2.2和2.3新建的两个主类 ?xml version1.0 encodingUTF-8? beans xmlnshttp://www.springframework.org/schema/beansxmlns:xsihttp://www.w3.org/2001/XMLSchema-instance xmlns:contexthttp://www.springframework.org/schema/contextxsi:schemaLocationhttp://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.xsdcontext:annotation-config /context:component-scan base-packagecom.study.demo /!--通过构造函数注入zkServers、sessionTimeout、zkPath从zookeeper动态获取数据库配置 --bean idzkConfigurerCentral classcom.study.demo.config.ZookeeperConfigurerCentralconstructor-arg namezkServers value192.168.152.130:2181 /constructor-arg namesessionTimeout value1000 /constructor-arg namezkPath value/Jdbc //bean!--这个类等价于以前在xml文件里面的配置context:property-placeholder locationclasspath:config/jdbc_conf.properties/ 加载props里面的数据库配置--bean idzkPlaceholderConfigurer classcom.study.demo.config.ZookeeperPlaceholderConfigurerproperty namezkConfigurerCentral refzkConfigurerCentral /property nameignoreUnresolvablePlaceholders valuetrue /property nameorder value1 //beanbean idjdbcTemplate classorg.springframework.jdbc.core.JdbcTemplateproperty namedataSourceref beandataSource //property/beanbean iddataSource classcom.zaxxer.hikari.HikariDataSourcedestroy-methodshutdownproperty namedriverClassName value${driver} /property namejdbcUrl value${url} /property nameusername value${uname} /property namepassword value${password} /!-- 连接只读数据库时配置为true 保证安全 --property namereadOnly valuefalse /!-- 等待连接池分配连接的最大时长毫秒超过这个时长还没可用的连接则发生SQLException 缺省:30秒 --property nameconnectionTimeout value30000 /!-- 一个连接idle状态的最大时长毫秒超时则被释放retired缺省:10分钟 --property nameidleTimeout value600000 /!-- 一个连接的生命时长毫秒超时而且没被使用则被释放retired缺省:30分钟建议设置比数据库超时时长少30秒参考MySQL wait_timeout参数show variables like %timeout%; --property namemaxLifetime value1800000 /!-- 连接池中允许的最大连接数。缺省值10推荐的公式((core_count * 2) effective_spindle_count) --property namemaximumPoolSize value15 //bean /beans 2.5 在com.study.demo.controller新建测试类 测试类1 package com.study.demo.controller;import java.io.Serializable;public class OrderModel implements Serializable {private static final long serialVersionUID 1L;private int orderId;private int brandId;public int getOrderId() {return orderId;}public void setOrderId(int orderId) {this.orderId orderId;}public int getBrandId() {return brandId;}public void setBrandId(int brandId) {this.brandId brandId;}} View Code 测试类2 package com.study.demo.controller;import java.sql.ResultSet; import java.sql.SQLException;import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowMapper; import org.springframework.stereotype.Repository;Repository public class OrderDao {Autowiredprivate JdbcTemplate jdbcTemplate;public OrderModel findById() {String sql select * from tbl_order where order_id 1;return jdbcTemplate.queryForObject(sql, new RowMapperOrderModel() {public OrderModel mapRow(ResultSet rs, int rowNum) throws SQLException {OrderModel payment new OrderModel();payment.setOrderId(rs.getInt(order_id));payment.setBrandId(rs.getInt(brand_id));return payment;}});} } View Code 测试类3 package com.study.demo.controller;import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service;Service public class OrderService {Autowiredprivate OrderDao dao;public OrderModel getById() {return dao.findById();} } View Code 测试类4 package com.study.demo.controller;import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody;Controller public class OrderController {Autowiredprivate OrderService service;ResponseBodyRequestMapping(value /test, method RequestMethod.GET)public String test() {OrderModel p service.getById();return p.getBrandId() ;} } View Code 2.6 其他附加配置和数据库脚本 /zkdemo/src/main/webapp/WEB-INF/config/log4j.properties log4j.rootLoggerINFO,console log4j.logger.org.apache.zookeeperDEBUG log4j.logger.org.apache.curatorDEBUG log4j.logger.java.lang.ExceptionINFOlog4j.appender.consoleorg.apache.log4j.ConsoleAppender log4j.appender.console.layoutorg.apache.log4j.PatternLayout log4j.appender.console.layout.ConversionPattern%d{MM-dd HH:mm:ss.SSS} [%c:%p] %m%n View Code /zkdemo/src/main/webapp/WEB-INF/config/spring-mvc.xml ?xml version1.0 encodingUTF-8 ? beans xmlnshttp://www.springframework.org/schema/beansxmlns:xsihttp://www.w3.org/2001/XMLSchema-instance xmlns:contexthttp://www.springframework.org/schema/contextxmlns:mvchttp://www.springframework.org/schema/mvc xmlns:aophttp://www.springframework.org/schema/aopxsi:schemaLocationhttp://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsdhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsdhttp://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsdmvc:default-servlet-handler /mvc:annotation-drivencontent-negotiation-managercontentNegotiationManager /context:component-scan base-packagecom.study.democontext:include-filter typeannotationexpressionorg.springframework.stereotype.Controller /context:exclude-filter typeannotationexpressionorg.springframework.stereotype.Service //context:component-scanbean idstringHttpMessageConverterclassorg.springframework.http.converter.StringHttpMessageConverterproperty namesupportedMediaTypeslistbean classorg.springframework.http.MediaTypeconstructor-arg index0 valuetext /constructor-arg index1 valueplain /constructor-arg index2 valueUTF-8 //bean/list/property/beanbean idmappingJacksonHttpMessageConverterclassorg.springframework.http.converter.json.MappingJackson2HttpMessageConverter /beanclassorg.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapterproperty namemessageConverterslistref beanstringHttpMessageConverter /ref beanmappingJacksonHttpMessageConverter //list/property/beanbean idcontentNegotiationManagerclassorg.springframework.web.accept.ContentNegotiationManagerFactoryBeanproperty namemediaTypesmapentry keyhtml valuetext/html /entry keypdf valueapplication/pdf /entry keyxsl valueapplication/vnd.ms-excel /entry keyxml valueapplication/xml /entry keyjson valueapplication/json //map/propertyproperty namedefaultContentType valuetext/html //beanbean idviewResolverclassorg.springframework.web.servlet.view.ContentNegotiatingViewResolverproperty nameorder value0 /property namecontentNegotiationManager refcontentNegotiationManager /property nameviewResolverslistbean classorg.springframework.web.servlet.view.BeanNameViewResolver /beanclassorg.springframework.web.servlet.view.InternalResourceViewResolverproperty nameviewClassvalueorg.springframework.web.servlet.view.JstlView /property nameprefix value/WEB-INF/pages/ /property namesuffix value.jsp/property/bean/list/propertyproperty namedefaultViewslistbeanclassorg.springframework.web.servlet.view.json.MappingJackson2JsonViewproperty nameextractValueFromSingleKeyModel valuetrue //bean/list/property/bean /beans View Code /zkdemo/src/main/webapp/WEB-INF/web.xml ?xml version1.0 encodingUTF-8? web-app idWebApp_ID version2.5xmlnshttp://java.sun.com/xml/ns/javaee xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsddisplay-namezkdemo/display-namedescriptionZookeeper Demo Application/description!-- --!-- Context parameters definition --!-- --context-paramparam-namewebAppRootKey/param-nameparam-valuezkdemo.root/param-value/context-paramcontext-paramparam-namelog4jConfigLocation/param-nameparam-value/WEB-INF/config/log4j.properties/param-value/context-paramcontext-paramparam-namelog4jRefreshInterval/param-nameparam-value60000/param-value/context-paramcontext-paramparam-namecontextConfigLocation/param-nameparam-value/WEB-INF/config/applicationContext.xml/param-value/context-paramservletservlet-namespring/servlet-nameservlet-classorg.springframework.web.servlet.DispatcherServlet/servlet-classinit-paramparam-namecontextConfigLocation/param-nameparam-value/WEB-INF/config/spring-mvc.xml/param-value/init-paramload-on-startup1/load-on-startup/servletservlet-mappingservlet-namespring/servlet-nameurl-pattern//url-pattern/servlet-mapping!-- --!-- Listener definition --!-- --listenerlistener-classorg.springframework.web.util.Log4jConfigListener/listener-class/listenerlistenerlistener-classorg.springframework.web.context.ContextLoaderListener/listener-class/listener!-- --!-- Filter definition --!-- --filterfilter-namecharacterEncodingFilter/filter-namefilter-classorg.springframework.web.filter.CharacterEncodingFilter/filter-classinit-paramparam-nameencoding/param-nameparam-valueUTF-8/param-value/init-paraminit-paramparam-nameforceEncoding/param-nameparam-valuetrue/param-value/init-param/filterfilter-mappingfilter-namecharacterEncodingFilter/filter-nameurl-pattern/*/url-pattern/filter-mapping!-- --!-- Web Session definition --!-- --session-configsession-timeout20/session-timeout/session-config!-- --!-- Redirect page definition --!-- --error-pageerror-code403/error-codelocation/403.jsp/location/error-pageerror-pageerror-code404/error-codelocation/404.jsp/location/error-pageerror-pageerror-code500/error-codelocation/500.jsp/location/error-page!-- --!-- First page definition --!-- --welcome-file-listwelcome-fileindex.htm/welcome-filewelcome-fileindex.jsp/welcome-file/welcome-file-list/web-app View Code 数据库脚本 CREATE TABLE tbl_order (order_id int(11) NOT NULL AUTO_INCREMENT COMMENT 订单id,brand_id int(11) DEFAULT NULL COMMENT 品牌id,PRIMARY KEY (order_id) ) ENGINEMyISAM AUTO_INCREMENT2 DEFAULT CHARSETutf8 COMMENT订单表;INSERT INTO tbl_order VALUES(1,1)  2.7 启动项目在浏览器输入地址http://localhost:8080/zkdemo/test查看效果   可以看到报错了这是因为我们之前设置了错误的url create /Jdbc/url jdbc.mysql://192.168.152.1/dbspread 修改url为正确的  set /Jdbc/url jdbc:mysql://192.168.152.1:3306/dbspread    再次输入地址访问查看效果 http://localhost:8080/zkdemo/test 可以看到在没有重启服务的情况下可以正常访问获取到值了这是因为zookeeper的数据库的配置动态刷新到服务了
http://www.zqtcl.cn/news/605371/

相关文章:

  • 网站建设需要哪些成本wordpress商城建站教程
  • 做网络的网站很重要吗网站认证费用
  • flash网站项目背景网页截图快捷键可拉动
  • 郑州企业建设网站北京企业网站模板建站开发
  • 宣传旅游网站建设的观点是什么公众号怎么推广和引流
  • 企业网站制作多少钱山西网络营销方案
  • 焦作住房和城乡建设局网站旅行网站模板
  • 男做基视频网站国家重点高新技术企业名单
  • 公司官方网站开发网站建设电子商务
  • seo网站优化系统搜索引擎优化排名案例
  • 郑州网站建设工作室网站建设全流程 知乎
  • 如何利用源码做网站外贸网站制作推广
  • 国内做网站哪家公司好免费查找资料的网站
  • 自己做的网站百度搜不到搭建网站seo
  • 奇墙网站建设高端网站建设公司联系电话
  • 宁波那家公司做网站好中企动力科技股份有限公司招聘
  • 水果网站推广网站首页静态好还是动态好
  • iis网站属性小程序源码无需服务器
  • 景区网站建设材料代运营有哪些套路坑
  • 六安电商网站建设哪家好有关做美食的网站
  • 卸载wordpress插件网店seo关键词
  • 金山网站制作赤城seo网站优化排名
  • 提供坪山网站建设深圳商城网站哪家做的好
  • 有什么网站可以帮人做模具吗热搜榜百度一下你就知道
  • 深圳网站优化技巧邹城住房城乡建设部网站
  • 小型企业网站建站桂林市中考信息网官网
  • 雏鸟app网站推广做网站用宋体有版权问题吗
  • 建立网站数据库开公司流程及费用2022最新
  • 外贸谷歌网站推广wordpress调用上传图片
  • 360提示危险网站原因威海 网站开发