Maven不会生成"persistence.xml"消息.文件 [英] Maven doesn't generate the "persistence.xml" file
问题描述
我阅读了本文在列出了不同目录布局的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=com.company.project.domain \
-DarchetypeGroupId=com.rfc.maven.archetypes \
-DarchetypeArtifactId=jpa-maven-archetype \
-DarchetypeVersion=1.0.0 \
-DremoteRepositories=http://maven.rodcoffin.com/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"消息.文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!