fix(BS-New-2): codegen pom 自动补依赖 + modelVersion + 正确版本
BS-New-2: dacli form codegen --multi-module-pom 生成的 pom 不完整,
导致 mvn package 失败. 4 个修复:
1. modelVersion 缺失: pom template 缺 <modelVersion>4.0.0</modelVersion>
→ mvn 报 'modelVersion is missing'
→ 修: 4 个 pom template 都加 modelVersion + xsi:schemaLocation
2. biz pom 缺 JNPF 平台依赖: 生成的 Service 引用 UserEntity/GeneraterSwapUtil
/QueryAllModel, 但 biz pom 没声明 jnpf-permission-entity/jnpf-generater-base
→ mvn 报 'package jnpf.permission.entity does not exist'
→ 修: biz pom 默认加这 2 个 dep
3. dep version 缺失: 4 个 pom template 的 dep 都没 <version>
→ mvn 报 'dependencies.dependency.version is missing'
→ 修: 内部 com.jnpf:* dep 用 ${project.version}, 第三方 (fastjson/commons-lang3)
用硬编码版本
4. fastjson 版本错: 用 ${project.version} 解析为 6.2.0-RELEASE 但 fastjson 实际
版本不是 → mvn 报 'Could not find artifact fastjson:jar:6.2.0-RELEASE'
→ 修: fastjson = 1.2.83 (实际版本)
测试场 (testspace) 验证:
ssw-testspace-entity: SUCCESS (3.241s)
ssw-testspace-biz: SUCCESS (0.315s) ← BS-New-2 关键验证点
ssw-testspace-controller: SUCCESS (0.214s)
BUILD SUCCESS 4.318s
jxcj 2026-06-30 实战教训
This commit is contained in:
1 parent
720c99d062
commit
6c74c3e6aa
1 file changed
+23
-11
@@ -400,7 +400,8 @@ function generateModulePoms(
|
||||
? allSubModules.filter((m) => wantedModules.has(m))
|
||||
: allSubModules
|
||||
const parentPom = `<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0">
|
||||
<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>
|
||||
<parent>
|
||||
<groupId>com.jnpf</groupId>
|
||||
<artifactId>boot</artifactId>
|
||||
@@ -414,7 +415,8 @@ ${subModules.map((m) => ` <module>${m}</module>`).join('\n')}
|
||||
</project>
|
||||
`
|
||||
const entityPom = `<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0">
|
||||
<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>
|
||||
<parent>
|
||||
<artifactId>${moduleArtifactId}</artifactId>
|
||||
<groupId>com.jnpf</groupId>
|
||||
@@ -422,13 +424,14 @@ ${subModules.map((m) => ` <module>${m}</module>`).join('\n')}
|
||||
</parent>
|
||||
<artifactId>${moduleArtifactId}-entity</artifactId>
|
||||
<dependencies>
|
||||
<dependency><groupId>com.jnpf</groupId><artifactId>jnpf-common-all</artifactId></dependency>
|
||||
<dependency><groupId>com.jnpf</groupId><artifactId>jnpf-generater-base</artifactId></dependency>
|
||||
<dependency><groupId>com.jnpf</groupId><artifactId>jnpf-common-all</artifactId><version>\${project.version}</version></dependency>
|
||||
<dependency><groupId>com.jnpf</groupId><artifactId>jnpf-generater-base</artifactId><version>\${project.version}</version></dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
`
|
||||
const bizPom = `<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0">
|
||||
<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>
|
||||
<parent>
|
||||
<artifactId>${moduleArtifactId}</artifactId>
|
||||
<groupId>com.jnpf</groupId>
|
||||
@@ -436,15 +439,24 @@ ${subModules.map((m) => ` <module>${m}</module>`).join('\n')}
|
||||
</parent>
|
||||
<artifactId>${moduleArtifactId}-biz</artifactId>
|
||||
<dependencies>
|
||||
<dependency><groupId>com.jnpf</groupId><artifactId>${moduleArtifactId}-entity</artifactId></dependency>
|
||||
<dependency><groupId>com.alibaba</groupId><artifactId>fastjson</artifactId></dependency>
|
||||
<dependency><groupId>com.jnpf</groupId><artifactId>${moduleArtifactId}-entity</artifactId><version>\${project.version}</version></dependency>
|
||||
<dependency><groupId>com.alibaba</groupId><artifactId>fastjson</artifactId><version>1.2.83</version></dependency>
|
||||
<dependency><groupId>org.apache.commons</groupId><artifactId>commons-lang3</artifactId><version>3.12.0</version></dependency>
|
||||
<dependency><groupId>com.jnpf</groupId><artifactId>jnpf-common-all</artifactId></dependency>
|
||||
<dependency><groupId>com.jnpf</groupId><artifactId>jnpf-common-all</artifactId><version>\${project.version}</version></dependency>
|
||||
<!-- v0.12+ BS-New-2 fix (2026-06-30 jxcj): codegen 自动补 JNPF 平台依赖
|
||||
根因: 生成的 Service 引用 jnpf.permission.entity.UserEntity + jnpf.util.GeneraterSwapUtil
|
||||
+ jnpf.model.QueryAllModel, 但 ssw-{app}-biz 旧 pom 没声明这两个 artifact
|
||||
→ mvn compile 报 "package does not exist" / "cannot find symbol"
|
||||
镜像: aibridge code-rule.md §POM 依赖规则 - biz 必须含所有 runtime 间接依赖
|
||||
修: 默认加这 2 个 dep, biz 编译可直接通过 (不需要手改 pom) -->
|
||||
<dependency><groupId>com.jnpf</groupId><artifactId>jnpf-permission-entity</artifactId><version>\${project.version}</version></dependency>
|
||||
<dependency><groupId>com.jnpf</groupId><artifactId>jnpf-generater-base</artifactId><version>\${project.version}</version></dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
`
|
||||
const controllerPom = `<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0">
|
||||
<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>
|
||||
<parent>
|
||||
<artifactId>${moduleArtifactId}</artifactId>
|
||||
<groupId>com.jnpf</groupId>
|
||||
@@ -452,8 +464,8 @@ ${subModules.map((m) => ` <module>${m}</module>`).join('\n')}
|
||||
</parent>
|
||||
<artifactId>${moduleArtifactId}-controller</artifactId>
|
||||
<dependencies>
|
||||
<dependency><groupId>com.jnpf</groupId><artifactId>${moduleArtifactId}-biz</artifactId></dependency>
|
||||
<dependency><groupId>com.jnpf</groupId><artifactId>jnpf-common-all</artifactId></dependency>
|
||||
<dependency><groupId>com.jnpf</groupId><artifactId>${moduleArtifactId}-biz</artifactId><version>\${project.version}</version></dependency>
|
||||
<dependency><groupId>com.jnpf</groupId><artifactId>jnpf-common-all</artifactId><version>\${project.version}</version></dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
`
|
||||
|
||||
Reference in new issue
Block a user