依赖标记内各种参数的标记化在初始化期间失败

发布于 2024-10-13 10:26:56 字数 2924 浏览 3 评论 0原文

以下依赖项是我的 pom.xml 文件的一部分,通过在 profile.xml 中选择适当的数据库配置文件,这些值将被正确替换。以下定义适用于 Maven 2.2.1,并在迁移到 Maven 3.0.2 后停止工作。如何解决这个问题?

    <dependency>
        <groupId>${db.groupId}</groupId>
        <artifactId>${db.artifactId}</artifactId>
        <version>${db.driver.version}</version>
        <scope>test</scope>
    </dependency>


<profile>
    <id>h2</id>
    <properties>
        <db.groupId>${db.h2.groupId}</db.groupId>
        <db.artifactId>${db.h2.artifactId}</db.artifactId>
        <db.type>h2</db.type>                <db.driver.version>${db.h2.driver.version</db.driver.version>
        <db.driver>${db.h2.driver}</db.driver>
    </properties>
</profile>

错误

[DEBUG] Looking up lifecyle mappings for packaging pom from ClassRealm[plex
us.core, parent: null]
[ERROR] The build could not read 1 project -> [Help 1]
org.apache.maven.project.ProjectBuildingException: Some problems were encou
ntered while processing the POMs:
[WARNING] The expression ${pom.url} is deprecated. Please use ${project.url
} instead. @
[ERROR] 'dependencyManagement.dependencies.dependency.artifactId' for ${db.
groupId}:${db.artifactId}:jar with value '${db.artifactId}' does not match
a valid id pattern. @ line 2488, column 29
[ERROR] 'dependencyManagement.dependencies.dependency.groupId' for ${db.gro
upId}:${db.artifactId}:jar with value '${db.groupId}' does not match a vali
d id pattern. @ line 2487, column 26
        at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProj
ectBuilder.java:325)
        at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:
632)
        at org.apache.maven.DefaultMaven.getProjectsForMavenReactor(Default
Maven.java:581)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:233)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:534)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessor
Impl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethod
AccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced
(Launcher.java:290)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launche
r.java:230)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCo
de(Launcher.java:409)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.
java:352)

The following dependency is part of my pom.xml file and by choosing an appropriate database profile in my profiles.xml, these values get substituted properly. The following definition was working on Maven 2.2.1 and has stopped working post migration to Maven 3.0.2. How do fix this issue?

    <dependency>
        <groupId>${db.groupId}</groupId>
        <artifactId>${db.artifactId}</artifactId>
        <version>${db.driver.version}</version>
        <scope>test</scope>
    </dependency>


<profile>
    <id>h2</id>
    <properties>
        <db.groupId>${db.h2.groupId}</db.groupId>
        <db.artifactId>${db.h2.artifactId}</db.artifactId>
        <db.type>h2</db.type>                <db.driver.version>${db.h2.driver.version</db.driver.version>
        <db.driver>${db.h2.driver}</db.driver>
    </properties>
</profile>

ERROR

[DEBUG] Looking up lifecyle mappings for packaging pom from ClassRealm[plex
us.core, parent: null]
[ERROR] The build could not read 1 project -> [Help 1]
org.apache.maven.project.ProjectBuildingException: Some problems were encou
ntered while processing the POMs:
[WARNING] The expression ${pom.url} is deprecated. Please use ${project.url
} instead. @
[ERROR] 'dependencyManagement.dependencies.dependency.artifactId' for ${db.
groupId}:${db.artifactId}:jar with value '${db.artifactId}' does not match
a valid id pattern. @ line 2488, column 29
[ERROR] 'dependencyManagement.dependencies.dependency.groupId' for ${db.gro
upId}:${db.artifactId}:jar with value '${db.groupId}' does not match a vali
d id pattern. @ line 2487, column 26
        at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProj
ectBuilder.java:325)
        at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:
632)
        at org.apache.maven.DefaultMaven.getProjectsForMavenReactor(Default
Maven.java:581)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:233)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:534)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessor
Impl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethod
AccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced
(Launcher.java:290)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launche
r.java:230)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCo
de(Launcher.java:409)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.
java:352)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

十二 2024-10-20 10:26:56

Maven 3.x 兼容性说明

The support for profiles outside of the POM or the settings.xml has been 
removed in version 3.x and users that previously used this feature are advised 
to move the affected profiles into their settings.xml.

这解释了您的问题并提出了解决方案。

From the Maven 3.x Compatibility notes,

The support for profiles outside of the POM or the settings.xml has been 
removed in version 3.x and users that previously used this feature are advised 
to move the affected profiles into their settings.xml.

This explains your problem as well as suggests the solution for it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文