如何使用Maven在WAR档案WEB-INF / lib中包含JAR?

时间:2018-01-15 17:14:15

标签: java maven war

My Maven SELECT "users"."id" AS t0_r0, "users"."username" AS t0_r1, "users"."created_at" AS t0_r2, "users"."updated_at" AS t0_r3, "users"."company_id" AS t0_r4, "users"."location_id" AS t0_r5, "subnets"."id" AS t1_r0, "subnets"."user_id" AS t1_r1, "devices"."id" AS t2_r0, "devices"."subnets_id" AS t2_r1, "devices"."updated_by" AS t2_r2, "devices"."created_by" AS t2_r3 FROM "users" LEFT OUTER JOIN "subnets" ON "subnets"."user_id" = "users"."id" LEFT OUTER JOIN "devices" ON "devices"."subnets_id" = "subnets"."id" WHERE "users"."id" = ? AND "users"."id" = 1 ORDER BY devices.updated_by desc 文件构建一个没有依赖项的pom,因此我必须手动将它们添加到WEB-INF / lib。

有没有办法指示Maven在war中包含所有依赖项? 因此war成为自我内容和独立

2 个答案:

答案 0 :(得分:2)

确保您的pom类型为war。 Maven的默认行为是 复制 依赖项在lib文件夹中。 附: 如果您发现任何问题,请发布完整的pom。 另外,请参阅maven war plugin了解更多文档

答案 1 :(得分:1)

是的,请确保包装类型为<packaging>war</packaging>类型。还要检查你的pom中的依赖项是否在正确的范围内,例如,如果它们不是默认值或编译范围,那么可能是为什么它们没有捆绑到war的lib文件夹中。

<dependency>
 ..
 ..
 <scope>compile</scope>
<dependency>