You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在Jira插件中集成OptaPlanner:求解器配置运行咨询

Hey there! Let's get your OptaPlanner integration up and running in your Jira plugin. Your current solverConfig.xml is missing critical sections—let's fill those in and cover all the key details to make it work smoothly.

Complete Solver Configuration Example

First, here's a full, functional version of your solverConfig.xml with explanations for each missing part:

<?xml version="1.0" encoding="UTF-8"?>
<solver xmlns="https://www.optaplanner.org/xsd/solver" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="https://www.optaplanner.org/xsd/solver https://www.optaplanner.org/xsd/solver/solver.xsd">

    <!-- Your existing domain class references -->
    <solutionClass>com.mycompany.planner.domain.VersionPlanning</solutionClass>
    <entityClass>com.mycompany.planner.domain.PlanningIssue</entityClass>

    <!-- Score calculation setup (extended with validation for development) -->
    <scoreDirectorFactory>
        <scoreDrl>planner/solver/scoreRules.drl</scoreDrl>
        <!-- Enable this to catch score calculation bugs during testing -->
        <assertScoreFromScratchEnabled>true</assertScoreFromScratchEnabled>
    </scoreDirectorFactory>

    <!-- Termination rules (critical: tells the solver when to stop) -->
    <termination>
        <!-- Stop after 30 seconds (adjust based on your performance needs) -->
        <secondsSpentLimit>30</secondsSpentLimit>
        <!-- Optional: Stop early if no score improvement for 5 seconds -->
        <unimprovedSecondsSpentLimit>5</unimprovedSecondsSpentLimit>
    </termination>

    <!-- Solver optimization phases (default setup works for most use cases) -->
    <constructionHeuristic>
        <constructionHeuristicType>FIRST_FIT_DECREASING</constructionHeuristicType>
    </constructionHeuristic>
    <localSearch>
        <localSearchType>HILL_CLIMBING</localSearchType>
    </localSearch>

    <!-- Thread management (safe for Jira's constrained environment) -->
    <moveThreadCount>AUTO</moveThreadCount>
</solver>
Key Integration Tips for Jira Plugins
  • Resource & Classpath Checks:

    • Make sure your scoreRules.drl lives in src/main/resources/planner/solver/ (for Maven/Gradle-based Jira plugins) so it gets packaged into your plugin JAR and is accessible at runtime.
    • Double-check that your VersionPlanning and PlanningIssue classes have the required OptaPlanner annotations: @PlanningSolution on the solution class, @PlanningEntity on the issue class, and @PlanningVariable on the field you're optimizing. Without these, the solver won't recognize your domain model.
  • Dependency Setup:

    • Add OptaPlanner to your plugin's build file (match the version to your Jira instance's Java version—Jira 9+ uses Java 11, so OptaPlanner 8.x is ideal):
      <!-- Maven pom.xml example -->
      <dependency>
          <groupId>org.optaplanner</groupId>
          <artifactId>optaplanner-core</artifactId>
          <version>8.44.0.Final</version> <!-- Use the latest compatible version -->
      </dependency>
      
  • Jira Runtime Best Practices:

    • Never run the solver in a Jira web request thread—it will block the request and cause timeouts. Use Atlassian's JobManager or a dedicated background executor to run solver jobs asynchronously.
    • Keep moveThreadCount conservative (or stick with AUTO)—Jira has its own thread pool limits, so avoid overloading the instance.
  • Test First:

    • Validate the solver works outside Jira first with a simple test:
      SolverFactory<VersionPlanning> solverFactory = SolverFactory.createFromXmlResource("planner/solver/solverConfig.xml");
      Solver<VersionPlanning> solver = solverFactory.buildSolver();
      
      // Create a sample unsolved solution
      VersionPlanning unsolved = new VersionPlanning();
      // Add sample PlanningIssue instances here...
      
      VersionPlanning solved = solver.solve(unsolved);
      System.out.println("Final score: " + solved.getScore());
      
Troubleshooting Quick Wins
  • If you get class not found errors, confirm your domain classes are packaged in the plugin JAR and their package names match the config exactly.
  • Score calculation bugs? The assertScoreFromScratchEnabled flag will validate that incremental score calculations match full recalculations, helping you spot issues in your DRL rules.
  • Deployment issues? Use atlas-run (Atlassian SDK) to test locally, and check Jira's atlassian-jira.log for OptaPlanner-specific error messages.

内容的提问来源于stack exchange,提问作者eldorado

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 07:58:29