首页
\
问答
\
spring-data-solr java.lang.IllegalArgumentException:不是托管类型(spring-data-solr java.lang.IllegalArgumentException: Not a managed type)
spring-data-solr java.lang.IllegalArgumentException:不是托管类型(spring-data-solr java.lang.IllegalArgumentException: Not a managed type)
我正在使用spring-data-solr,但我不能让它工作:( ..
春天我还是新手,我想我设置好每一件事,你能帮助我吗?
非常感谢你
*************************** APPLICATION FAILED TO START *************************** Description: Field userSearchResultSolrRepository in com.dateup.models.solr.StartupSync required a bean of type 'com.dateup.repositories.solr.UserSearchResultSolrRepository' that could not be found. Action: Consider defining a bean of type 'com.dateup.repositories.solr.UserSearchResultSolrRepository' in your configuration.
这是我的代码:
我设置依赖
... <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-solr</artifactId> <version>2.1.3.RELEASE</version> </dependency> ....
@Configuration @EnableSolrRepositories(basePackages = {"com.dateup.repositories.solr.*"}, multicoreSupport = true) public class SearchContext { }
import org.joda.time.LocalDate; import org.springframework.data.annotation.Id; import org.springframework.data.solr.core.mapping.Indexed; import org.springframework.data.solr.core.mapping.SolrDocument; @SolrDocument(solrCoreName = "collection1") public class UserSearchResultSolr { @Id @Indexed public Long id; @Indexed public String name; ..... }
import org.springframework.data.solr.repository.SolrCrudRepository; public interface UserSearchResultSolrRepository extends SolrCrudRepository<UserSearchResultSolr, String> { }
@Component public class StartupSync { @Autowired private UserRepository m_userRepository; @Autowired private UserSearchResultSolrRepository userSearchResultSolrRepository; @PostConstruct public void syncSolr() {
谢谢
i am using spring-data-solr, but i can't make it to work :(..
i am still new to spring, i think i setup every thing, can you help me please.
thank you very much
*************************** APPLICATION FAILED TO START *************************** Description: Field userSearchResultSolrRepository in com.dateup.models.solr.StartupSync required a bean of type 'com.dateup.repositories.solr.UserSearchResultSolrRepository' that could not be found. Action: Consider defining a bean of type 'com.dateup.repositories.solr.UserSearchResultSolrRepository' in your configuration.
Here is my code:
i setup the dependency
... <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-solr</artifactId> <version>2.1.3.RELEASE</version> </dependency> ....
@Configuration @EnableSolrRepositories(basePackages = {"com.dateup.repositories.solr.*"}, multicoreSupport = true) public class SearchContext { }
import org.joda.time.LocalDate; import org.springframework.data.annotation.Id; import org.springframework.data.solr.core.mapping.Indexed; import org.springframework.data.solr.core.mapping.SolrDocument; @SolrDocument(solrCoreName = "collection1") public class UserSearchResultSolr { @Id @Indexed public Long id; @Indexed public String name; ..... }
import org.springframework.data.solr.repository.SolrCrudRepository; public interface UserSearchResultSolrRepository extends SolrCrudRepository<UserSearchResultSolr, String> { }
@Component public class StartupSync { @Autowired private UserRepository m_userRepository; @Autowired private UserSearchResultSolrRepository userSearchResultSolrRepository; @PostConstruct public void syncSolr() {
thank you
原文:https://stackoverflow.com/questions/43823757
更新时间:2023-02-05 14:02
最满意答案
基于https://github.com/graphql-python/graphene/issues/110 ,正确的方法是使用字符串:
class FolderNode(DjangoObjectType): folders = graphene.List('FolderNode')
Based on https://github.com/graphql-python/graphene/issues/110, the correct way to do this is with a string:
class FolderNode(DjangoObjectType): folders = graphene.List('FolderNode')
相关问答
更多-
使用tuple unpacking - 您可以返回多个结果,并从func接收多个结果 text, text2 = cls.method_1() 另外你最好不要将你的变量命名为text和text2。 而且cls是一个用于类的常用词,在你的代码中cls是一个实例,这有点unpythonic :) Use tuple unpacking - you can return several results, and receive several results from a func text, text2 = ...
-
在类Foo或其任何子类的一个方法中, self.CONSTANT将引用在类Foo为该类属性定义的值(除非它在子类中或实例本身中被覆盖 - 如果指定 self.CONSTANT=23 ,它是使用该值创建的实例属性,并在将来的引用中覆盖类属性)。 Within a method of class Foo or any subclass thereof, self.CONSTANT will refer to the value defined for that class attribute in class ...
-
尝试在while循环和run方法之外声明数据变量。 然后,您可以使用httpReq.data调用该静态变量 供参考: Python中的静态类变量 It turns out that there are various ways of doing this. For my purposes however, (since only one thread writes to the variable, and the others read-only) I have found that using a glo ...
-
无法以这种方式重写代码。 你能做的最接近的是: class MyClass: pass def test(x, y, z=external_function(MyClass): pass MyClass.test = staticmethod(test) del test 请注意,这假设Python 3; 在Python 2中,您可能需要摆弄new模块。 但尽管这是可能的,但代码的意图非常明显。 if z is None ,或者重构代码不需要它,最好坚持使用。 It is no ...
-
在ctypes.Structure的文档中,它解释了如何执行此操作: 可以在定义Structure子类的类语句之后定义_fields_类变量,这允许创建直接或间接引用自身的数据类型 这意味着您可以添加: class python_format(ctypes.Structure): # forward declaration pass 然后在定义OPENFUNC (和其他函数类型)之后: OPENFUNC = ctypes.CFUNCTYPE(ctypes.POINTER( python_form ...
-
定义类变量,它引用python中的前一个类变量(Define class variable which refers to a previous class variable in python)[2021-06-19]
class Foo(object): a = "/admin' b = a + '/hello' class Foo(object): a = "/admin' b = a + '/hello' -
基于https://github.com/graphql-python/graphene/issues/110 ,正确的方法是使用字符串: class FolderNode(DjangoObjectType): folders = graphene.List('FolderNode') Based on https://github.com/graphql-python/graphene/issues/110, the correct way to do this is with a string ...
-
你可以使用@property装饰器来实现: class C2(): def __init__(self, c1): self.c1 = c1 @property def variable(self): return self.c1.variable 如果你想修改C2实例中的variable : @variable.setter def variable(self, value): self.c1.variable = ...
-
使用some_name = ...分配新变量总是在最里面的封闭范围内创建变量(除非global或非nonlocal正在运行,但它们在这里不相关)。 在对象上分配新属性名称会在该对象上创建属性。 所以self.foo = 1在当前由self引用的对象上分配一个名为foo的属性。 通常,名称self用作方法的第一个参数,该方法接收调用该方法的对象。 所以“用自我定义一个变量”并不是什么特别的东西; 它只是关于在现有对象上分配属性的普通规则。 实例对象本身中存在的任何属性显然必须特定于该实例。 在Polygon类 ...
-
如果要在nodes保留最后一个列表/元组的值而不将它们重置为0.0 ,则需要创建该对象的副本( nodes[-1] )或手动将它们复制到新的列表/元组对象中如果我理解正确的话,那就是你的目标。 您目前只是在通过二维数组进行交互并将所有值重置为0.0之前创建对节点[-1]的引用,这意味着, out仍将引用您重置为0.0值的内存中的引用对象。 out = nodes[-1].copy() # This is the list/tuple with the (non-reset) values that you ...