1.eclipse 插件有问题:生成的GlobalServiceConfig.xml下的<monitor-config>应该改为:
<monitor-config> <storage-provider name="DAOMetricsStorageProvider"> <class-name>org.ebayopensource.turmeric.monitoring.storage.DAOMetricsStorageProvider </class-name> <storage-options> <option name="persistenceUnitName">metrics</option> <option name="metricsDAOClassName">org.ebayopensource.turmeric.monitoring.MetricsDAOImpl </option> <option name="storeServiceMetrics">false</option> </storage-options> </storage-provider> <snapshot-interval>60</snapshot-interval> </monitor-config>
并在src目录下添加persistence.xml
<?xml version="1.0" encoding="UTF-8"?> <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0"> <persistence-unit name="metrics" transaction-type="RESOURCE_LOCAL"> <class>org.ebayopensource.turmeric.utils.jpa.model.Persistent</class> <class>org.ebayopensource.turmeric.monitoring.model.Machine</class> <class>org.ebayopensource.turmeric.monitoring.model.MachineGroup</class> <class>org.ebayopensource.turmeric.monitoring.model.Metric</class> <class>org.ebayopensource.turmeric.monitoring.model.MetricClassifier</class> <class>org.ebayopensource.turmeric.monitoring.model.MetricComponentDef</class> <class>org.ebayopensource.turmeric.monitoring.model.MetricDef</class> <class>org.ebayopensource.turmeric.monitoring.model.MetricValue</class> <class>org.ebayopensource.turmeric.monitoring.model.MetricComponentValue</class> <class>org.ebayopensource.turmeric.runtime.error.model.Error</class> <class>org.ebayopensource.turmeric.runtime.error.model.ErrorValue</class> <exclude-unlisted-classes>true</exclude-unlisted-classes> <properties> <property name="hibernate.connection.provider_class" value="com.jolbox.bonecp.provider.BoneCPConnectionProvider"/> <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" /> <property name="hibernate.connection.url" value="jdbc:mysql://localhost/turmericdb" /> <property name="hibernate.connection.username" value="turmeric" /> <property name="hibernate.connection.password" value="turmeric" /> <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" /> <property name="hibernate.hbm2ddl.auto" value="update" /> </properties> </persistence-unit> <persistence-unit name="policyservice" transaction-type="RESOURCE_LOCAL"> <class>org.ebayopensource.turmeric.utils.jpa.model.Persistent</class> <class>org.ebayopensource.turmeric.utils.jpa.model.AuditablePersistent</class> <class>org.ebayopensource.turmeric.policyservice.model.Subject</class> <class>org.ebayopensource.turmeric.policyservice.model.SubjectType</class> <class>org.ebayopensource.turmeric.policyservice.model.SubjectGroup</class> <class>org.ebayopensource.turmeric.policyservice.model.Policy</class> <class>org.ebayopensource.turmeric.policyservice.model.Resource</class> <class>org.ebayopensource.turmeric.policyservice.model.Operation</class> <class>org.ebayopensource.turmeric.policyservice.model.Rule</class> <class>org.ebayopensource.turmeric.policyservice.model.PrimitiveValue</class> <class>org.ebayopensource.turmeric.policyservice.model.Expression</class> <class>org.ebayopensource.turmeric.policyservice.model.Condition</class> <class>org.ebayopensource.turmeric.policyservice.model.AuditHistory</class> <class>org.ebayopensource.turmeric.policyservice.model.BasicAuth</class> <exclude-unlisted-classes>true</exclude-unlisted-classes> <properties> <property name="hibernate.connection.provider_class" value="com.jolbox.bonecp.provider.BoneCPConnectionProvider"/> <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" /> <property name="hibernate.connection.url" value="jdbc:mysql://localhost/turmericdb" /> <property name="hibernate.connection.username" value="turmeric" /> <property name="hibernate.connection.password" value="turmeric" /> <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" /> <property name="hibernate.hbm2ddl.auto" value="update" /> </properties> </persistence-unit> <persistence-unit name="errors" transaction-type="RESOURCE_LOCAL"> <class>org.ebayopensource.turmeric.utils.jpa.model.Persistent</class> <class>org.ebayopensource.turmeric.runtime.error.model.Error</class> <class>org.ebayopensource.turmeric.runtime.error.model.ErrorValue</class> <exclude-unlisted-classes>true</exclude-unlisted-classes> <properties> <property name="hibernate.connection.provider_class" value="com.jolbox.bonecp.provider.BoneCPConnectionProvider"/> <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" /> <property name="hibernate.connection.url" value="jdbc:mysql://localhost/turmericdb" /> <property name="hibernate.connection.username" value="turmeric" /> <property name="hibernate.connection.password" value="turmeric" /> <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" /> <property name="hibernate.hbm2ddl.auto" value="update" /> </properties> </persistence-unit> </persistence>
如此,MyDemoServiceV1Impl项目才能正常打包
2.部署到etty之后,slf4j报异常,因为版本太低,要升级到1.6.1版本。
3.报异常 No Persistence provider for EntityManager named metrics
请在 目录mydemoservice-war\src\main\webapp\WEB-INF\classes\META-INF下添加persistence.xml 文件
4.PersistenceUnit: metrics] Unable to build EntityManagerFactory
java.lang.ClassNotFoundException: com.jolbox.bonecp.provider.BoneCPConnectionProvider
请在pom.xml文件中添加:
<dependency> <groupId>org.ebayopensource.turmeric.monitoring</groupId> <artifactId>turmeric-monitoring-dao-provider</artifactId> <version>1.0.0.4-SNAPSHOT</version>
</dependency> <dependency> <groupId>org.ebayopensource.turmeric.monitoring</groupId> <artifactId>monitoring-metrics-jpa</artifactId> <version>1.0.1.0-SNAPSHOT</version> </dependency> <dependency> <groupId>com.jolbox</groupId> <artifactId>bonecp</artifactId> <version>0.7.1.RELEASE</version> </dependency>
<dependency> <groupId>com.jolbox</groupId> <artifactId>bonecp-provider</artifactId> <version>0.7.1.RELEASE</version> </dependency>
4.新建项目,要使用JPA 在pom.xml中引入:
<dependency> <groupId>org.ebayopensource.turmeric.monitoring</groupId> <artifactId>monitoring-metrics-jpa</artifactId> <version>1.0.1.0-SNAPSHOT</version> </dependency>
加载mvn包的网址 http://mvnrepository.com