KieScanner无法自动获取最新版本! [英] KieScanner cannot fetch LATEST version automatically!

查看:86
本文介绍了KieScanner无法自动获取最新版本!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将drools工作台6.4.0.Final与我自己的应用程序集成在一起.

I want to integrate the drools workbench 6.4.0.Final with my own application.

下面是主要类:

package com.example;
import com.idss.poc.CouponFact;
import com.idss.poc.Result;
import org.codehaus.plexus.util.FileUtils;
import org.drools.compiler.kie.builder.impl.KieServicesImpl;
import org.drools.compiler.kproject.ReleaseIdImpl;
import org.drools.core.io.impl.UrlResource;
import org.kie.api.KieServices;
import org.kie.api.builder.KieModule;
import org.kie.api.builder.KieRepository;
import org.kie.api.builder.KieScanner;
import org.kie.api.builder.ReleaseId;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.StatelessKieSession;
import org.kie.scanner.KieScannerFactoryServiceImpl;

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


public class FunctionExample {
    public static void main(String[] args) {
        KieServices ks = KieServices.Factory.get();
        ReleaseId releaseId = ks.newReleaseId( "com.test", "poc", "LATEST" );

        KieContainer kContainer = ks.newKieContainer(releaseId);
        KieScanner kieScanner = ks.newKieScanner(kContainer);

        kieScanner.start( 10000L );

        Scanner scanner = new Scanner(System.in);

        while (true) {
            kieScanner.scanNow();
            String line = scanner.nextLine();
            runRule(kContainer);
        }
    }

    private static void runRule(KieContainer kieKontainer) {
        StatelessKieSession kSession =kieKontainer.newStatelessKieSession("ks");
        Result result = new Result();
        List<String> list = new ArrayList<String>();
        result.setRules(list);

        kSession.setGlobal("result", result);

        CouponFact cf = new CouponFact();
        cf.setPhoneCount(2);
        cf.setUserCount(2);
        cf.setDeviceCount(2);
        cf.setIp10mCount(10);
        cf.setIpDayCount(10);
        kSession.execute(cf);

        System.out.println(result.getScore() + "," + result.getRules());
    }
}

这是我自己的应用程序使用的我的settings.xml.

This below is my settings.xml used by own application.

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" 
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <localRepository>~/.m2/repository</localRepository>
  <pluginGroups>
  </pluginGroups>
  <proxies>
  </proxies>
  <servers>
    <server>
      <id>guvnor-m2-repo</id>
      <username>workbench</username>
      <password>workbench!</password>
      <configuration>
        <wagonProvider>httpclient</wagonProvider>
        <httpConfiguration>
          <all>
            <usePreemptive>true</usePreemptive>
          </all>
        </httpConfiguration>
      </configuration>
    </server>
    <server>
      <id>mymirror</id>
      <username>workbench</username>
      <password>workbench!</password>
      <configuration>
        <wagonProvider>httpclient</wagonProvider>
        <httpConfiguration>
          <all>
            <usePreemptive>true</usePreemptive>
          </all>
        </httpConfiguration>
      </configuration>
    </server>
  </servers>
  <mirrors>
    <mirror>
      <id>mymirror</id>
      <url>http://10.10.10.57:8080/kie-wb/maven2</url>
      <mirrorOf>*</mirrorOf>
      <layout>default</layout>
    </mirror>
  </mirrors>
  <profiles>
    <profile>
      <id>guvnor-m2-repo</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <repositories>
        <repository>
            <id>guvnor-m2-repo</id>
            <name>Guvnor M2 Repo</name>
            <url>http://10.10.10.57:8080/kie-wb/maven2</url>
            <releases>
              <enabled>true</enabled>
            </releases>
            <updatePolicy>always</updatePolicy>
        </repository>
      </repositories>
    </profile>
  </profiles>
  <activeProfiles>
   <activeProfile>guvnor-m2-repo</activeProfile>
  </activeProfiles>
</settings>

当我在工作台中更新我的Drools规则并升级回购版本时,我的应用程序不会自动获得回购的最新版本.我得到这样的日志:

When I update my drools rule in workbench, and upgrade the version of my repo, but my application do not get the LATEST version of my repo automatically. I get the log like this:

11:50:24.158 [Timer-0] DEBUG org.kie.scanner.embedder.MavenEmbedderUtils - Not in OSGi: using plexus based maven parser
11:50:24.212 [Timer-0] DEBUG org.eclipse.aether.internal.impl.DefaultLocalRepositoryProvider - Using manager EnhancedLocalRepositoryManager with priority 10.0 for /Users/pinter/Desktop/RiskGuard/~/.m2/repository
11:50:24.212 [Timer-0] DEBUG org.eclipse.aether.internal.impl.DefaultLocalRepositoryProvider - Using manager EnhancedLocalRepositoryManager with priority 10.0 for /Users/pinter/Desktop/RiskGuard/~/.m2/repository
11:50:24.213 [Timer-0] DEBUG org.eclipse.aether.internal.impl.DefaultRemoteRepositoryManager - Using mirror mymirror (http://10.10.10.57:8080/kie-wb/maven2) for guvnor-m2-repo (http://10.10.10.57:8080/kie-wb/maven2).
11:50:24.215 [Timer-0] DEBUG org.eclipse.aether.internal.impl.DefaultRemoteRepositoryManager - Using mirror mymirror (http://10.10.10.57:8080/kie-wb/maven2) for guvnor-m2-repo (http://10.10.10.57:8080/kie-wb/maven2).
11:50:24.215 [Timer-0] DEBUG org.eclipse.aether.internal.impl.DefaultRemoteRepositoryManager - Using mirror mymirror (http://10.10.10.57:8080/kie-wb/maven2) for central (https://repo.maven.apache.org/maven2).
11:50:24.216 [Timer-0] DEBUG org.eclipse.aether.internal.impl.DefaultDependencyCollector - Dependency collection stats: {ConflictMarker.analyzeTime=0, ConflictMarker.markTime=0, ConflictMarker.nodeCount=1, ConflictIdSorter.graphTime=0, ConflictIdSorter.topsortTime=0, ConflictIdSorter.conflictIdCount=0, ConflictIdSorter.conflictIdCycleCount=0, ConflictResolver.totalTime=0, ConflictResolver.conflictItemCount=0, DefaultDependencyCollector.collectTime=0, DefaultDependencyCollector.transformTime=0}
11:50:24.217 [Timer-0] DEBUG org.eclipse.aether.internal.impl.DefaultLocalRepositoryProvider - Using manager EnhancedLocalRepositoryManager with priority 10.0 for ~/.m2/repository
11:50:24.217 [Timer-0] DEBUG org.eclipse.aether.internal.impl.DefaultUpdateCheckManager - Skipped remote request for com.idss:poc/maven-metadata.xml, locally cached metadata up-to-date.

有人可以帮我弄清楚吗?谢谢!

Can anyone help me to figure it out? Thank you!

推荐答案

如果您在应用程序的版本号字段中使用 LATEST ,则 KieScanner 尝试匹配该版本本地存储库中可用的jar的编号,以及在kie-workbench上可用的jar的版本号.如果两个版本相同,则不会从远程存储库获取jar,而使用本地存储库中的jar.每次构建和部署"时,请增加版本号,以使更改反映在应用程序端.

If you are using LATEST in version number field in your application, KieScanner try to match the version number of the jar available in the local repository with version number of jar available at kie-workbench. If both the version are same, it doesn't fetch the jar from remote repository and uses the jar from local repository. Each time you 'build and deploy', do increment your version number for the changes to get reflected on your application side.

如果每次部署都增加版本号对您来说工作量太大,我建议您在版本号中使用 -SNAPSHOT .即使本地存储库中提供了相同的版本,也始终会从远程存储库中获取快照版本.< version> -SNAPSHOT 仅应用于开发目的.

If incrementing the version number each time you deploy is too much of work for you, I would suggest using the -SNAPSHOT in your version number. The snapshot version are always fetched from the remote repository even if the same version is available in local repo. <version>-SNAPSHOT should be used for development purpose only.

这篇关于KieScanner无法自动获取最新版本!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆