Maven不会生成"persistence.xml"消息.文件

编程入门 行业动态 更新时间:2024-10-23 05:39:15
本文介绍了Maven不会生成"persistence.xml"消息.文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我阅读了本文在列出了不同目录布局的maven项目网页上(例如:src/main/resources用于应用程序/库资源).

I read this article on the maven project web page that lists the different directory layouts (like: src/main/resources which is for Application/Library resources).

问题是,当我运行以下命令时(在这里找到):

The problem is that when I run the following command (found here):

mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

未创建src/main/resources/META-INF目录.这对我很重要,因为我想访问该目录中的"persistence.xml".

the src/main/resources/META-INF directory isn't created. It's important for me because I'd like to reach the "persistence.xml" that is found in that directory.

我应该在mvn命令中添加一个选项吗?如何自动生成包含"META-INF/persistence.xml"文件的"src/main/resources"?

Should I add an option in the mvn command? How can I automatically generate the "src/main/resources" that contains the "META-INF/persistence.xml" file?

谢谢你, 问候

推荐答案

问题是,当我运行以下命令(...)时,未创建src/main/resources/META-INF目录.这对我很重要,因为我想访问该目录中的"persistence.xml".

The problem is that when I run the following command (...) the src/main/resources/META-INF directory isn't created. It's important for me because I'd like to reach the "persistence.xml" that is found in that directory.

Maven快速入门原型不会创建src/main/resources或src/test/resources.有几种解释:

The maven quickstart archetype does NOT create src/main/resources nor src/test/resources. There are several explanations:

  • 如其名称所述,此原型允许快速启动项目,具体取决于您的形状.
  • 为什么这个原型应该创建src/main/resources而不能创建src/main/assembly?
  • 长时间以来,实际上不可能创建空目录(请参阅 ARCHETYPE-57 ).
  • As stated by its name, this archetype allows to quickstart a project, it's up to you to shape it.
  • Why should this archetype create src/main/resources and not, say, src/main/assembly?
  • Creating empty directories was actually not possible during a long time (see ARCHETYPE-57).

换句话说,如果使用此原型,只需手动添加src/main/resources/META-INF/persistence.xml.

In other words, just add src/main/resources/META-INF/persistence.xml manually if you use this archetype.

我应该在mvn命令中添加一个选项吗?如何自动生成包含"META-INF/persistence.xml"文件的"src/main/resources"?

Should I add an option in the mvn command? How can I automatically generate the "src/main/resources" that contains the "META-INF/persistence.xml" file?

您不能拥有这种原型-我真的不明白为什么这是一个如此大的问题.

You can't with this archetype - and I don't really understand why this is a such big issue.

虽然有一个JPA原型:

There is a JPA archetype though:

mvn archetype:create \ -DgroupId=com.mycompany.project \ -DartifactId=my-project-domain \ -DpackageName=company.project.domain \ -DarchetypeGroupId=com.rfc.maven.archetypes \ -DarchetypeArtifactId=jpa-maven-archetype \ -DarchetypeVersion=1.0.0 \ -DremoteRepositories=maven.rodcoffin/repo

这将创建以下引导JPA项目:

That creates the following bootstrap JPA project:

$ tree my-project-domain/ my-project-domain/ ├── pom.xml └── src ├── main │   ├── java │   │   └── com │   │   └── company │   │   └── project │   │   └── domain │   │   └── User.java │   └── resources │   └── META-INF │   └── persistence.xml └── test ├── java │   └── com │   └── company │   └── project │   └── domain │   ├── DbUnitDataLoader.java │   └── UserTest.java └── resources └── user.db.xml 16 directories, 6 files

更多推荐

Maven不会生成"persistence.xml"消息.文件

本文发布于:2023-10-25 14:07:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1527180.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:消息   文件   quot   Maven   xml

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!