- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
我的文凭项目有一个大问题,如果你们能帮助我,我会非常高兴!我做了一个 Maven 多模块项目并有 3 个“核心项目”
NaviClean
:(父)NaviCleanDomain
:包含域模型以及我的所有实体和NaviCleanServer
需要的接口(interface) MeinRemoteDienst
和 NaviCleanCleint
用于 Hessianprotocol
NaviCleanClient
:包含 GUI 和 Hessian 连接到NaviCleanServer
NaviCleanServer
:这是我的存储库,我与数据库的连接以及接口(interface)einRemoteDienst
的实现NaviCleanServer
& NaviCleanClient
在 Maven 中有 NaviCleanDomain
作为依赖关系。现在每次我尝试在我的 Tomcat 上启动服务器时都会收到以下错误:
ERROR: org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'transaktionsRepository':
Injection of persistence dependencies failed;
nested exception is org.springframework.beans.factory.CannotLoadBeanClassException:
Error loading class [at.naviclean.service.impl.MeinRemoteDienstImpl] for bean with name 'meinRemoteDienstImpl' defined in file [C:\Users\Fredy\Documents\workspace-sts-3.1.0.RELEASE\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\NaviCleanServer\WEB-INF\classes\at\naviclean\service\impl\MeinRemoteDienstImpl.class]:
problem with class file or dependent class;
nested exception is java.lang.NoClassDefFoundError: at/naviclean/service/MeinRemoteDienst
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessPropertyValues(PersistenceAnnotationBeanPostProcessor.java:342)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)
……………….
模型库:
package at.naviclean.domain;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Version;
@SuppressWarnings("serial")
@MappedSuperclass
public class ModelBase implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
private Long id;
@Version
@Column(name = "ts")
private Date timestamp;
public Long getId() {
return id;
}
public Date getTimestamp() {
return timestamp;
}
public void setId(Long id) {
this.id = id;
}
public void setTimestamp(Date timestamp) {
this.timestamp = timestamp;
}
}
卡萨:
package at.naviclean.domain;
import javax.persistence.Column;
import javax.persistence.Entity;
@SuppressWarnings("serial")
@Entity
public class Kassa extends ModelBase {
@Column(name = "name", unique = true)
private String name;
@Column(name = "geld")
private int geld;
public Kassa(String name, int geld) {
this.name = name;
this.geld = geld;
}
public Kassa() {
}
public String getName() {
return name;
}
public int getGeld() {
return geld;
}
public void setName(String name) {
this.name = name;
}
public void setGeld(int geld) {
this.geld = geld;
}
}
MeinRemoteDienst:
package at.naviclean.service;
import at.naviclean.domain.Kassa;
public interface MeinRemoteDienst {
int getKassaCount(int plus);
String getNameFromKassa(int id);
Kassa findById(int id);
}
BaseRepository
package at.naviclean.repositories;
import org.springframework.data.jpa.repository.JpaRepository;
import at.naviclean.domain.ModelBase;
public interface BaseRepository<T extends ModelBase> extends
JpaRepository<T, Long> {
T findById(long id);
}
KassaRepository:
package at.naviclean.repositories;
import java.util.List;
import org.springframework.data.jpa.repository.Query;
import at.naviclean.domain.Kassa;
public interface KassaRepository extends BaseRepository<Kassa> {
List<Kassa> findByGeld(int geld);
Kassa findByName(String name);
@Query("select k from Kassa k where k.geld = ?1")
Kassa findByGeld1(int geld);
}
MeinRemoteDienstImpl:
package at.naviclean.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import at.naviclean.domain.Kassa;
import at.naviclean.repositories.KassaRepository;
import at.naviclean.service.MeinRemoteDienst;
@Service
public class MeinRemoteDienstImpl implements MeinRemoteDienst {
@Autowired(required = true)
public KassaRepository kassaR;
public int getKassaCount(int plus) {
return 2;
}
public String getNameFromKassa(int id) {
return kassaR.findById(id + 0l).getName();
}
@Override
public Kassa findById(int id) {
return = kassaR.findById(id + 0l);
}
}
application-context.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:repository="http://www.springframework.org/schema/data/repository"
xsi:schemaLocation="http://www.springframework.org/schema/data/repository http://www.springframework.org/schema/data/repository/spring-repository.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<import resource="infrastructures.xml" />
<jpa:repositories base-package="at.naviclean.repositories">
<repository:exclude-filter type="regex"
expression="at.naviclean.repositories.BaseRepository" />
</jpa:repositories>
<context:component-scan base-package="at.naviclean.service.impl" />
</beans>
infrastructures.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="true" />
<property name="generateDdl" value="true" />
<property name="databasePlatform" value="org.hibernate.dialect.MySQLDialect" />
</bean>
</property>
</bean>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost/kassatest" />
<property name="username" value="root" />
<property name="password" value="" />
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" />
</beans>
servlet-context.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:c="http://www.springframework.org/schema/c"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<import resource="../root-context.xml" />
<bean id="idMeinRemoteDienst" class="at.naviclean.service.impl.MeinRemoteDienstImpl" />
<bean name="/MeinRemoteDienstHessian"
class="org.springframework.remoting.caucho.HessianServiceExporter"
p:serviceInterface="at.naviclean.service.MeinRemoteDienst"
p:service-ref="idMeinRemoteDienst" />
</beans>
root-context.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<import resource="classpath:META-INF/spring/application-context.xml" />
</beans>
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- The definition of the Root Spring Container shared by all Servlets
and Filters -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/root-context.xml</param-value>
</context-param>
<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>/MeinRemoteDienstHessian</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>/MeinRemoteDienstHessian</servlet-name>
<url-pattern>/remoting/*</url-pattern>
</servlet-mapping>
</web-app>
这是我已经尝试过的:1. 我写了这个“变红”的测试:
package at.spengergasse.kassa;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import at.naviclean.domain.Kassa;
import at.naviclean.repositories.KassaRepository;
@ContextConfiguration("classpath:META-INF/spring/application-context.xml")
@RunWith(SpringJUnit4ClassRunner.class)
public class KassaTest {
@Autowired(required = true)
private KassaRepository kassaR;
@Before
public void setUp() throws Exception {
}
@Test
public void findByIdTest() {
Kassa k = kassaR.findById(2);
assertThat(k, is(not(nullValue())));
}
@Test
public void findByGeld() {
Kassa k = kassaR.findByGeld1(1200);
assertThat(k, is(not(nullValue())));
}
@Test
public void test() {
Kassa vorher = new Kassa("ssf", 222);
kassaR.save(vorher);
Kassa nachher = kassaR.findById(vorher.getId());
kassaR.delete(nachher);
assertThat(vorher.getId(), is(equalTo(nachher.getId())));
}
}
错误:
ERROR: org.springframework.test.context.TestContextManager -
Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@41e22632] to prepare test instance [at.spengergasse.kassa.KassaTest@6639be68]
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:157)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:321)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:211)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:288)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:290)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'meinRemoteDienstImpl':
**Injection of autowired dependencies failed**;
nested exception is org.springframework.beans.factory.BeanCreationException:
Could not autowire field: public at.naviclean.repositories.KassaRepository at.naviclean.service.impl.MeinRemoteDienstImpl.kassaR;
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'kassaRepository': FactoryBean threw exception on object creation;
nested exception is java.lang.IllegalArgumentException: **Not an managed type: class at.naviclean.domain.Kassa**
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:287)
………..
2.我在我的 persitence.xml 我的 domainmodel 中手动插入了一个存储库。结果是“绿色”测试,但我仍然无法启动服务器...
提前非常感谢!!!我无法想象没有你会怎样:)
最佳答案
Oliver Gierke 给了我一个非常有用的建议:
The last exception you get actually indicates a problem with your JPA setup. "Not a managed bean" means not a type the JPA provider is aware of. If you're setting up a Spring based JPA application I'd recommend to configure the "packagesToScan" property on the LocalContainerEntityManagerFactory you have configured to the package that contains your JPA entities. Alternatively you can list all your entity classes in persistence.xml, but that's usually more cumbersome.
The former error you got (NoClassDefFound) indicates the class mentioned is not available on the projects classpath. So you might wanna check the inter module dependencies you have. As the two relevant classes seem to be located in the same module it might also just be an issue with an incomplete deployment to Tomcat (WTP is kind of bitchy sometimes). I'd definitely recommend to run a test for verification (as you already did). As this seems to lead you to a different exception, I guess it's really some Eclipse glitch
谢谢!
关于java - Autowiring 失败 : Not an managed Type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14069449/
假设a是张量,那么有什么区别: 类型(a) a.类型 a.type() 我找不到区分这些的文档。 最佳答案 type 是 python 内置方法。 它将返回对象的类型。喜欢 torch.Tensor.
什么是 Type 1 的居民的例子?两者都不是 Type也不是Type的居民?在 Idris REPL 中进行探索时,我无法想出任何东西。 更准确地说,我正在寻找一些 x除了 Type产生以下结果:
我找到了一些资源,但我不确定我是否理解。 我找到的一些资源是: http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb2ff3358411d1829f00
这两个函数原型(prototype)有什么区别? void apply1(double(f)(double)); void apply2(double(*f)(double)); 如果目标是将提供的函
http://play.golang.org/p/icQO_bAZNE 我正在练习使用堆进行排序,但是 prog.go:85: type bucket is not an expression
假设有一个泛型定义的方法信息对象,即一个方法信息对象,这样的方法Info.IsGenericMethodDefinition==TRUE:。也可以说它们也有一个泛型参数列表:。我可以使用以下命令获取该
在具有依赖类型的语言中,您可以使用 Type-in-Type 来简化语言并赋予它很多功能。这使得语言在逻辑上不一致,但如果您只对编程感兴趣而不对定理证明感兴趣,这可能不是问题。 在 Cayenne
根据 Nim 手册,变量类型是“静态类型”,而变量在内存中指向的实际值是“动态类型”。 它们怎么可能是不同的类型?我认为将错误的类型分配给变量将是一个错误。 最佳答案 import typetrait
假设您有以下结构和协议(protocol): struct Ticket { var items: [TicketItem] = [] } struct TicketItem { } prot
我正在处理一个 EF 问题,我发现它很难调试...以前,在我的系统中有一个表类型继承设置管理不同的用户类型 - 所有用户共有的一种根类型,以及大致基于使用该帐户的人员类型的几种不同的子类型。现在,我遇
这是我的 DBManager.swift import RealmSwift class DBManager { class func getAllDogs() -> [Dog] {
我正在尝试使用傅里叶校正图像中的曝光。这是我面临的错误 5 padded = np.log(padded + 1) #so we never have log of 0 6 g
关闭。这个问题是opinion-based .它目前不接受答案。 想要改进这个问题? 更新问题,以便 editing this post 可以用事实和引用来回答它. 关闭 9 年前。 Improve
请考虑以下设置: protocol MyProcotol { } class MyModel: MyProcotol { } enum Result { case success(value:
好吧,我将我的 python 项目编译成一个可执行文件,它在我的电脑上运行,但我将它发送给几个 friend 进行测试,他们都遇到了这个错误。我以前从未见过这样的错误。我使用 Nuitka 来编译代码
当我尝试训练我的模型时"ValueError: Type must be a sub-type of ndarray type"出现在 line x_norm=(np.power(x,2)).sum(
我尝试在另一个类中打断、计数然后加入对象。所以我构建协议(protocol): typealias DataBreaker = () -> [Double] typealias DataJoiner
我正在使用 VS 2015 更新 3、Angular 2.1.2、Typescript 2.0.6 有人可以澄清什么是 typings 与 npm @types 以及本月很难找到的任何其他文档吗? 或
我正在考虑从 VS2010 更改为 Mono,因此我通过 MoMA 运行我的程序集,看看我在转换过程中可能遇到多少困难。在生成的报告中,我发现我不断收到此错误: bool Type.op_Equali
主要问题 不太确定这是否可能,但由于我讨厌 Typescript 并且它使我的编码变得困难,我想我会问只是为了确定。 interface ISomeInterface { handler: ()
我是一名优秀的程序员,十分优秀!