使用Maven 2,有没有一种方法可以将jar依赖项列为文件名?
mvn dependency:build-classpath
Run Code Online (Sandbox Code Playgroud)
可以列出jar文件,但这将包括它们在我的本地存储库中的位置的完整路径.我需要的只是一个文件名列表(或复制依赖目标复制的文件名).
所以我需要的清单就像是
activation-1.1.jar,antlr-2.7.6.jar,aopalliance-1.0.jar etc...
Run Code Online (Sandbox Code Playgroud)
理想情况下,作为maven属性,但我想,像build-classpath这样的文件可以生成.
我想要实现的是Bundle-ClassPath为OSGi包编写一个手动维护的MANIFEST.MF文件.(您不应该理解这一点来回答这个问题.)
澄清一下:问题不在于如何将清单头文件写入jar中的MANIFEST.MF文件中(很容易google).我问的是如何获取我想要写的数据,即上面显示的列表.
我想在hossnate 4.3中使用JBoss 7.1中的多租户功能.
我设法通过在jboss-deployment-structure中添加以下行来将它包含在我的战争中
<exclusions>
<module name="org.hibernate" />
</exclusions>
Run Code Online (Sandbox Code Playgroud)
并在我的pom.xml中为hibernate核心和实体管理器添加依赖项
这使得hibernate 4.3加载但不幸的是我收到了一个错误
java.lang.NoSuchMethodError: javax.persistence.Table.indexes()[Ljavax/persistence/Index;
Run Code Online (Sandbox Code Playgroud)
这是由于在hibernate 4.3使用JPA 2.1时加载了JPA 2.0
我已经看过这些线程并尝试了他们的建议 从JBoss EAP 6.1中排除JPA子系统 - 尝试在JBoss EAP 6.1中使用JPA 2.1,JBoss AS7自动加载JPA,Hibernate 4.3.0.Final和Spring Data JPA 1.4.3.RELEASE.
我添加了一个persistence.xml
<property name="jboss.as.jpa.managed" value="false" />
Run Code Online (Sandbox Code Playgroud)
从Spring Data中排除了hibernate jpa 2.0
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>${spring-data.version}</version>
<exclusions>
<exclusion>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
</exclusion>
</exclusions>
</dependency>
Run Code Online (Sandbox Code Playgroud)
从JBoss standalone.xml中完全删除了JPA子系统,没有任何成功.
唯一能做到这一点的是在jboss-deployment-structure中排除整个javaee.api,如另一个线程所示
<exclusions>
<module name="javax.persistence.api"/>
<module name="javaee.api"/>
</exclusions>
Run Code Online (Sandbox Code Playgroud)
但这会给我的其余代码带来许多问题.
更新:我的jboss-deployment-structure.xml现在是这样的
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="org.slf4j" />
<module name="org.slf4j.impl" />
<module name="org.apache.log4j" /> …Run Code Online (Sandbox Code Playgroud) 我正在升级jpa,hibernate,spring和jdk以启用JPA 2.1的新功能.但是我收到以下错误:
java.lang.NoSuchMethodError: javax.persistence.Table.indexes()[Ljavax/persistence/Index;
Run Code Online (Sandbox Code Playgroud)
我已阅读有关此内容的其他帖子,但他们无法解决我的计算机上的错误.例如,SJuan76对这篇文章的回答建议升级到jpa 2.1,但我已经将eclipse jpa项目方面设置为2.1版,我也将其包含hibernate-jpa-2.1-api在我的pom.xml中.您可以通过单击此链接阅读完整pom.xml中各种库的所有版本. 我需要在pom.xml或eclipse项目中更改以解决此错误?
注意:我可以通过将pom.xml中的hibernate版本更改回来来消除错误<hibernate.version>4.2.1.Final</hibernate.version>,但这会破坏升级的目的.改变hibernate版本的事实是否打开和关闭错误有助于我们诊断问题?
如果问题是多个罐子彼此冲突,我可以使用eclipse类型管理器禁用其中一个罐子,但我会找哪个罐子?
这是完整的堆栈跟踪:
ERROR ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [spring/business-config.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax.persistence.Table.indexes()[Ljavax/persistence/Index;
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1553) ~[spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539) ~[spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475) ~[spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302) ~[spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298) ~[spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) ~[spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:973) ~[spring-context-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:750) ~[spring-context-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482) ~[spring-context-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389) …Run Code Online (Sandbox Code Playgroud) 我们正在尝试使用Hibernate将Java 7 Spring MVC应用程序部署到IBM WebSphere 8.5.5.2服务器中.应用程序在Tomcat服务器上运行良好,但我们无法在WebSphere中运行它.
堆栈跟踪输出如下:
[3/26/15 13:49:53:552 MDT] 00000066 AutowiredAnno I org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor <init> JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
[3/26/15 13:49:54:299 MDT] 00000066 LocalContaine I org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean createNativeEntityManagerFactory Building JPA container EntityManagerFactory for persistence unit 'default'
[3/26/15 13:49:54:339 MDT] 00000066 LogHelper Z org.hibernate.jpa.internal.util.LogHelper logPersistenceUnitInformation HHH000204: Processing PersistenceUnitInfo [
name: default
...]
[3/26/15 13:49:54:536 MDT] 00000066 Version Z org.hibernate.Version logVersion HHH000412: Hibernate Core {4.3.7.Final}
[3/26/15 13:49:54:543 MDT] 00000066 Environment Z org.hibernate.cfg.Environment <clinit> HHH000206: hibernate.properties not found
[3/26/15 13:49:54:546 …Run Code Online (Sandbox Code Playgroud) 我可以使用Maven的插件运行Spring Boot,spring-boot:run但是当我尝试执行打包后,jar它给出了:
Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax.persistence.Table.indexes( [Ljavax/persistence/Index
Run Code Online (Sandbox Code Playgroud)
Pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>123</groupId>
<artifactId>event</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<url>http://maven.apache.org</url>
<name>Event</name>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.1.6.RELEASE</version>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<start-class>go.Application</start-class>
<guava.version>16.0.1</guava.version>
<java.version>1.7</java.version>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
</plugin>
<!-- Spring Boot Maven -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.5</version>
<configuration>
<archive>
<manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration> …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 hibernate 注释测试一些 POJO,并且我不断收到相同的错误。我在另一个项目中使用了相同的配置,一切正常。我测试了测试 hib 对象时使用的 jdbc 连接 - 并且连接工作正常。
我发现了一些其他关于相同错误的问题,但没有任何帮助。
带有main方法的测试类中的代码:
public static void main(String[] args) {
SessionFactory factory = new Configuration()
.configure("hibernate.cfg.xml")
.addAnnotatedClass(Item.class)
.buildSessionFactory();
//create session
Session session = factory.getCurrentSession();
try {
session.beginTransaction();
List<Item> items = session.createQuery("from items").list();
Run Code Online (Sandbox Code Playgroud)
带有休眠注释的 POJO:
@Entity
@Table(name="items")
public class Item {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="id")
private int id;
@Column(name="name")
private String name;
@Column(name="price")
private double price;
@Column(name="stock")
private int stock;
public Item() {
}
public Item(String name, double price) {
this.name = name;
this.price …Run Code Online (Sandbox Code Playgroud) java ×5
hibernate ×4
jpa ×2
maven ×2
classpath ×1
dependencies ×1
eclipse ×1
jakarta-ee ×1
jar ×1
jboss7.x ×1
jpa-2.0 ×1
jpa-2.1 ×1
jpa-2.2 ×1
maven-2 ×1
spring-boot ×1
spring-mvc ×1
websphere ×1