Я пытаюсь внедрить сервер Solr, используя @bean
в конфигурационном файле, но безуспешно.
Как я могу решить эту проблему?
Мой код:
@Entity
@Configurable(preConstruction = true, autowire = Autowire.BY_TYPE)
@Table(name = "content_package")
public class ContentPackage implements Serializable {
private static final long serialVersionUID = 1L;
private static Logger logger = Logger.getLogger(ContentPackage.class);
@NotNull
@Size(max = 1024)
@Column(columnDefinition = "nvarchar(1024)", name = "name")
@Localized
private String Name;
@Size(max = 1024)
@Column(columnDefinition = "nvarchar(1024)", name = "display_name")
@Localized
private String displayName;
@Column(columnDefinition = "nvarchar(max)", name = "description")
@Localized
private String Description;
@Autowired
transient SolrServer solrServer;
public static SolrServer solrServer() {
SolrServer _solrServer = new ContentPackage().solrServer; // this line is giving null
if (_solrServer == null)
throw new IllegalStateException(
"Solr server has not been injected(is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)");
return _solrServer;
}
}
Ошибка:
Сервер Solr не может использовать Solrserver.
Контекст приложения:
<context:component-scan base-package="com.ceb.shl.shlonline">
<context:exclude-filter expression=".*Roo.*" type="regex" />
<context:exclude-filter expression="org.springframework.stereotype.Controller" type="annotation"/>
</context:component-scan>
<bean class="org.apache.solr.client.solrj.impl.HttpSolrServer" id="solrServer">
<constructor-arg value="${solr.serverUrl}"/>
</bean>
<bean id="myApplicationListener" class="com.ceb.shl.shlonline.util.LoadSolrData">
<property name="shouldIndex" value="true"/>
</bean>