Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Maven 2 初始化期间,依赖项标记内各种参数的标记化失败_Maven 2_Maven_Maven 3 - Fatal编程技术网

Maven 2 初始化期间,依赖项标记内各种参数的标记化失败

Maven 2 初始化期间,依赖项标记内各种参数的标记化失败,maven-2,maven,maven-3,Maven 2,Maven,Maven 3,以下依赖项是我的pom.xml文件的一部分,通过在my profiles.xml中选择适当的数据库概要文件,可以正确地替换这些值。以下定义在Maven 2.2.1上工作,在迁移到Maven 3.0.2后已停止工作。如何解决这个问题 <dependency> <groupId>${db.groupId}</groupId> <artifactId>${db.artifactId}</artifactId&

以下依赖项是我的pom.xml文件的一部分,通过在my profiles.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>


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

您是否使用配置文件运行maven?如果是这样的话,你能编辑上面的内容并发布相关的配置文件片段吗?我已经添加了一些关于配置文件的信息。注意:此pom.xml在2.2.1中没有任何更改,其中定义了“h2”相关属性,如db.h2.groupId、db.h2.artifactId?h2特定属性在pom.xml中,配置文件信息在profiles.xml文件中。这些定义通过配置文件初始化,不幸的是,maven解析器正在尝试解析pom.xml,并且似乎看不到它们的有效引用。
[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 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.