当前位置: 首页>編程日記>正文

urule客户端和服务器配置

urule客户端和服务器配置

urule服务端配置(包含数据库的配置):

pom文件:

<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.bstek.urule</groupId><artifactId>urule-springboot</artifactId><version>0.0.1-SNAPSHOT</version><properties><java.version>1.7</java.version><tomcat.version>8.5.5</tomcat.version><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding></properties><licenses><license><name>The Apache License, Version 2.0</name><url>http://www.apache.org/licenses/LICENSE-2.0.txt</url></license></licenses><developers><developer><name>Gaojie</name><email>jacky.gao@bstek.com</email><organization>Bstek</organization><organizationUrl>http://www.bstek.com</organizationUrl></developer></developers><scm><connection>https://github.com/youseries/urule.git</connection><developerConnection>https://github.com/youseries/urule.git</developerConnection><url>https://github.com/youseries/urule</url></scm><organization><name>Bstek</name><url>http://www.bstek.com</url></organization><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.0.3.RELEASE</version><relativePath /></parent><dependencies><dependency><groupId>com.ecms</groupId><artifactId>cbc.account.urule</artifactId><version>1.0-SNAPSHOT</version></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>5.1.40</version></dependency><dependency><groupId>com.alibaba</groupId><artifactId>druid</artifactId><version>1.1.10</version></dependency><dependency><groupId>com.bstek.urule</groupId><artifactId>urule-console-pro</artifactId><version>2.1.3</version><exclusions><exclusion><groupId>org.slf4j</groupId><artifactId>slf4j-jdk14</artifactId></exclusion><exclusion><groupId>com.bstek.urule</groupId><artifactId>urule-core-pro</artifactId></exclusion></exclusions></dependency><dependency><groupId>javax.servlet</groupId><artifactId>servlet-api</artifactId><version>2.5</version><scope>provided</scope></dependency></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build><distributionManagement><snapshotRepository><id>ossrh</id><url>https://oss.sonatype.org/content/repositories/snapshots</url></snapshotRepository><repository><id>ossrh</id><url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url></repository></distributionManagement><name>Urule Springboot Project</name><url>https://github.com/youseries/urule/tree/master/urule-springboot</url><issueManagement><url>https://github.com/youseries/urule/issues</url></issueManagement><description>Urule Springboot Project</description>
</project>

urule-console-datasource.properties:

spring.datasource.name=mydatasource
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://192.168.103.11:3306/cbc?characterEncoding=utf8&allowMultiQueries=true&autoReconnect=true
spring.datasource.username=cbc
spring.datasource.password=cbc@20180907spring.datasource.initialSize=5
spring.datasource.minIdle=5
spring.datasource.maxActive=20
spring.datasource.maxWait=60000
spring.datasource.timeBetweenEvictionRunsMillis=60000
spring.datasource.minEvictableIdleTimeMillis=300000
spring.datasource.validationQuery=SELECT 1 FROM DUAL
spring.datasource.testWhileIdle=true
spring.datasource.testOnBorrow=false
spring.datasource.testOnReturn=false
spring.datasource.poolPreparedStatements=true
spring.datasource.maxPoolPreparedStatementPerConnectionSize=20
spring.datasource.filters=stat,wall,slf4j

application.properties:

server.port=7888
#urule.repository.dir=d:/repo
urule.repository.datasourcename=mydatasource
urule.repository.databasetype=mysql

 config文件:

package com.bstek.urule.springboot;import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;import javax.sql.DataSource;@Configuration
@ImportResource({"classpath:urule-console-context.xml"})
@PropertySource(value = {"classpath:urule-console-datasource.properties"})
public class Config {/*** PropertySourcesPlaceholderConfigurer:外部属性配置文件,可以替换xml中的属性配置,实现部分私密配置外部化,类似数据库配置* @return*/@Beanpublic PropertySourcesPlaceholderConfigurer propertySourceLoader(){PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();//该属性为true,将会隐藏在占位符变量无法解析或者属性文件不存在是抛出的异常configurer.setIgnoreUnresolvablePlaceholders(true);configurer.setOrder(1);return configurer;}@Bean(name = "mydatasource")@ConfigurationProperties(prefix = "spring.datasource")public DataSource dataSource(){return DataSourceBuilder.create().type(com.alibaba.druid.pool.DruidDataSource.class).build();}
}

 对于urule需要用到的动作库,可以另外定义一个jar包,在服务端和客户端分别依赖该jar包,这样在客户端和服务端中都可以不在依赖urule的jar包。

indexServlet:

package com.bstek.urule.springboot;import java.io.IOException;import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;/*** @author Jacky.gao* @since 2016年10月12日*/
public class IndexServlet extends HttpServlet {private static final long serialVersionUID = 9155627652423910928L;@Overrideprotected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {resp.sendRedirect(req.getContextPath()+"/urule/frame");}
}

UruleServletRegistration:

package com.bstek.urule.springboot;import javax.servlet.http.HttpServlet;import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;import com.bstek.urule.console.servlet.URuleServlet;/*** @author Jacky.gao* @since 2016年10月12日*/
@Component
public class URuleServletRegistration {/*** springboot自带的支持servlet的注册方法,接收两个参数,第一个是自定义的servlet,第二个是对符合路径的访问跳转到第一个配置的servlet上* @return*/@Beanpublic ServletRegistrationBean<HttpServlet> registerURuleServlet(){return new ServletRegistrationBean<HttpServlet>(new URuleServlet(),"/urule/*");}@Beanpublic ServletRegistrationBean<HttpServlet> registerIndexServlet(){return new ServletRegistrationBean<HttpServlet>(new IndexServlet(),"/");}}

 活动库项目(actionRepository):

pom文件:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.ecms</groupId><artifactId>cbc.account.urule</artifactId><version>1.0-SNAPSHOT</version><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><org.springframework.version>5.0.8.RELEASE</org.springframework.version></properties><dependencies><dependency><groupId>com.ecms</groupId><artifactId>cbc-api</artifactId><version>1.0.0-SNAPSHOT</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-context</artifactId><version>${org.springframework.version}</version><scope>provided</scope></dependency><dependency><groupId>com.alibaba</groupId><artifactId>fastjson</artifactId><version>1.2.44</version></dependency><dependency><groupId>org.apache.commons</groupId><artifactId>commons-lang3</artifactId><version>3.7</version></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>1.16.22</version></dependency><dependency><groupId>com.bstek.urule</groupId><artifactId>urule-core-pro</artifactId><version>2.1.3</version><exclusions><exclusion><groupId>org.slf4j</groupId><artifactId>slf4j-jdk14</artifactId></exclusion></exclusions></dependency><dependency><groupId>org.apache.httpcomponents</groupId><artifactId>httpclient</artifactId><version>4.5.2</version></dependency></dependencies><repositories><repository><id>sonatype</id><url>https://oss.sonatype.org/content/groups/public/</url></repository></repositories><build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-source-plugin</artifactId><executions><execution><id>attach-sources</id><goals><goal>jar</goal></goals></execution></executions></plugin></plugins></build>
</project>

活动库项目为简单的java项目,只需要定义具体的方法即可,方法的写法可以参考官方网站的说明。另外urule中也可以定义通用的工具类。

客户端:

客户端pom文件: 

<dependency><groupId>com.ecms</groupId><artifactId>cbc.account.urule</artifactId><version>1.0-SNAPSHOT</version></dependency>
<dependency><groupId>com.bstek.urule</groupId><artifactId>urule-core-pro</artifactId><version>2.1.3</version><exclusions><exclusion><groupId>org.springframework</groupId><artifactId>spring-web</artifactId></exclusion><exclusion><groupId>org.slf4j</groupId><artifactId>slf4j-jdk14</artifactId></exclusion></exclusions></dependency>

关于urule的包只需要引入core-pro和自己定义的活动库项目的jar包,core-pro中因为引入了日志和web模块,但是我的项目中自己定义了需要的相关模块,所有启动报错,同理,对不同的项目,如果产生了jar包冲突,可以自行排除。

urule.properties:

urule.knowledgeUpdateCycle=1
urule.resporityServerUrl=http://localhost:7888

里面只需要指定服务端的url和知识库的拉取策略。

UruleConfig:

package executor.config;import com.bstek.urule.KnowledgePackageReceiverServlet;
import com.bstek.urule.URulePropertyPlaceholderConfigurer;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
import org.springframework.core.io.ClassPathResource;@Configuration
@ImportResource(locations = {"classpath:urule-core-context.xml"})
public class UruleConfig {@Beanpublic ServletRegistrationBean<KnowledgePackageReceiverServlet> servletRegistrationBean(){return new ServletRegistrationBean<KnowledgePackageReceiverServlet>(new KnowledgePackageReceiverServlet(),"/knowledgepackagereceiver");}@Beanpublic URulePropertyPlaceholderConfigurer uRuleConfig (){URulePropertyPlaceholderConfigurer config = new URulePropertyPlaceholderConfigurer();config.setLocation(new ClassPathResource("urule.properties"));return config;}}

最后一步,在springboot的启动类中引入对自定义动作库的扫描即可。以上即为springboot整合urule的全部工作。

 

 

 

 

 

 


https://www.fengoutiyan.com/post/15273.html

相关文章:

  • urule模型
  • 服务器和客户端的连接
  • 服务器和客户端区别
  • vue路由配置
  • 连接服务器
  • 服务器U
  • Urule
  • vultr服务器
  • 鏡像模式如何設置在哪,圖片鏡像操作
  • 什么軟件可以把圖片鏡像翻轉,C#圖片處理 解決左右鏡像相反(旋轉圖片)
  • 手機照片鏡像翻轉,C#圖像鏡像
  • 視頻鏡像翻轉軟件,python圖片鏡像翻轉_python中鏡像實現方法
  • 什么軟件可以把圖片鏡像翻轉,利用PS實現圖片的鏡像處理
  • 照片鏡像翻轉app,java實現圖片鏡像翻轉
  • 什么軟件可以把圖片鏡像翻轉,python圖片鏡像翻轉_python圖像處理之鏡像實現方法
  • matlab下載,matlab如何鏡像處理圖片,matlab實現圖像鏡像
  • 圖片鏡像翻轉,MATLAB:鏡像圖片
  • 鏡像翻轉圖片的軟件,圖像處理:實現圖片鏡像(基于python)
  • canvas可畫,JavaScript - canvas - 鏡像圖片
  • 圖片鏡像翻轉,UGUI優化:使用鏡像圖片
  • Codeforces,CodeForces 1253C
  • MySQL下載安裝,Mysql ERROR: 1253 解決方法
  • 勝利大逃亡英雄逃亡方案,HDU - 1253 勝利大逃亡 BFS
  • 大一c語言期末考試試題及答案匯總,電大計算機C語言1253,1253《C語言程序設計》電大期末精彩試題及其問題詳解
  • lu求解線性方程組,P1253 [yLOI2018] 扶蘇的問題 (線段樹)
  • c語言程序設計基礎題庫,1253號C語言程序設計試題,2016年1月試卷號1253C語言程序設計A.pdf
  • 信奧賽一本通官網,【信奧賽一本通】1253:抓住那頭牛(詳細代碼)
  • c語言程序設計1253,1253c語言程序設計a(2010年1月)
  • 勝利大逃亡英雄逃亡方案,BFS——1253 勝利大逃亡
  • 直流電壓測量模塊,IM1253B交直流電能計量模塊(艾銳達光電)
  • c語言程序設計第三版課后答案,【渝粵題庫】國家開放大學2021春1253C語言程序設計答案
  • 18轉換為二進制,1253. 將數字轉換為16進制
  • light-emitting diode,LightOJ-1253 Misere Nim
  • masterroyale魔改版,1253 Dungeon Master
  • codeformer官網中文版,codeforces.1253 B
  • c語言程序設計考研真題及答案,2020C語言程序設計1253,1253計算機科學與技術專業C語言程序設計A科目2020年09月國家開 放大學(中央廣播電視大學)
  • c語言程序設計基礎題庫,1253本科2016c語言程序設計試題,1253電大《C語言程序設計A》試題和答案200901
  • 肇事逃逸車輛無法聯系到車主怎么辦,1253尋找肇事司機