依赖

<dependency>
    <groupId>org.apache.maven</groupId>
    <artifactId>maven-model</artifactId>
    <version>3.0</version>
</dependency>

示例代码:

        MavenXpp3Reader reader = new MavenXpp3Reader();
        String myPom = rootPath + File.separator + "pom.xml";
        Model model = null;
        try {
            model = reader.read(new FileReader(myPom));
        } catch (IOException e) {
            e.printStackTrace();
        } catch (XmlPullParserException e) {
            e.printStackTrace();
        }
        String artifactId = model.getArtifactId();
        System.out.println(artifactId);
posted on 2021-05-10 15:32  一贯可乐  阅读(745)  评论(0编辑  收藏  举报



123