小编Shi*_*mar的帖子

如何在Spring中自动装配泛型类型<T>的Bean?

我有一个bean Item<T>需要在@Configuration课堂上自动装配.

@Configuration
public class AppConfig {

    @Bean
    public Item<String> stringItem() {
        return new StringItem();
    }

    @Bean
    public Item<Integer> integerItem() {
        return new IntegerItem();
    }

}
Run Code Online (Sandbox Code Playgroud)

但是当我尝试时@Autowire Item<String>,我得到以下异常.

"No qualifying bean of type [Item] is defined: expected single matching bean but found 2: stringItem, integerItem"
Run Code Online (Sandbox Code Playgroud)

我应该如何Item<T>在Spring中自动加载通用类型?

java generics spring autowired spring-annotations

66
推荐指数
2
解决办法
6万
查看次数

Project facet Java version 1.7 is not supported

When i update my java I found the issue "Project facet Java version 1.7 is not supported" To resolve this issue follow the steps.

  1. Go to Ecllipse , right click on your project folder
  2. select the properties
  3. now select Project Facets ,here you will see java, click on the version and change the higher version to lower or as per your requirement .

在此输入图像描述

java eclipse project facets

34
推荐指数
2
解决办法
5万
查看次数

如何在solr中编写嵌套的schema.xml?

如何在solr中编写嵌套的schema.xml

schema.xml中的文档说

<!-- points to the root document of a block of nested documents. Required for nested
document support, may be removed otherwise
-->
<field name="_root_" type="string" indexed="true" stored="false"/>
Run Code Online (Sandbox Code Playgroud)

http://svn.apache.org/viewvc/lucene/dev/trunk/solr/example/solr/collection1/conf/schema.xml?view=markup

哪个可以使用

https://cwiki.apache.org/confluence/display/solr/Other+Parsers#OtherParsers-BlockJoinQueryParsers

什么是schema.xml用于嵌套以下项目:

  • 人字符串
  • 地址
    • 城市字符串
    • 邮政编码字符串

configuration schema solr solr4

17
推荐指数
1
解决办法
7386
查看次数

RestEasy - UnsupportedMediaTypeException:无法使用内容类型

我有一个Spring MVC REST服务,应该接收混合的mime内容.控制器定义为

    @POST
    @Path("/createMime")
    @Consumes("multipart/mixed")
    @ResponseStatus(HttpStatus.OK)
    public String createMime(@Context ServletContext servletContext, MultipartInput input) throws MyRestException {

        logger.info("Processing /createMime");

        return "TEST";
    }
Run Code Online (Sandbox Code Playgroud)

当我测试上面我得到以下错误:

17:18:58,456 WARN  [org.jboss.resteasy.core.SynchronousDispatcher] (http--127.0.0.1-8080-1) Failed executing POST services/createMime: org.jboss.resteasy.spi.UnsupportedMediaTypeException: Cannot consume content type
        at org.jboss.resteasy.core.registry.Segment.match(Segment.java:112) [resteasy-jaxrs-2.2.1.GA.jar:]
        at org.jboss.resteasy.core.registry.SimpleSegment.matchSimple(SimpleSegment.java:33) [resteasy-jaxrs-2.2.1.GA.jar:]
        at org.jboss.resteasy.core.registry.RootSegment.matchChildren(RootSegment.java:327) [resteasy-jaxrs-2.2.1.GA.jar:]
        at org.jboss.resteasy.core.registry.SimpleSegment.matchSimple(SimpleSegment.java:44) [resteasy-jaxrs-2.2.1.GA.jar:]
        at org.jboss.resteasy.core.registry.RootSegment.matchChildren(RootSegment.java:327) [resteasy-jaxrs-2.2.1.GA.jar:]
        at org.jboss.resteasy.core.registry.RootSegment.matchRoot(RootSegment.java:374) [resteasy-jaxrs-2.2.1.GA.jar:]
        at org.jboss.resteasy.core.registry.RootSegment.matchRoot(RootSegment.java:367) [resteasy-jaxrs-2.2.1.GA.jar:]
        at org.jboss.resteasy.core.ResourceMethodRegistry.getResourceInvoker(ResourceMethodRegistry.java:251) [resteasy-jaxrs-2.2.1.GA.jar:]
        at org.jboss.resteasy.core.SynchronousDispatcher.getInvoker(SynchronousDispatcher.java:173) [resteasy-jaxrs-2.2.1.GA.jar:]
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:118) [resteasy-jaxrs-2.2.1.GA.jar:]
        at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208) [resteasy-jaxrs-2.2.1.GA.jar:]
        at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55) [resteasy-jaxrs-2.2.1.GA.jar:]
        at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50) [resteasy-jaxrs-2.2.1.GA.jar:]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) …
Run Code Online (Sandbox Code Playgroud)

java rest spring multipart resteasy

6
推荐指数
1
解决办法
1万
查看次数

将 tools.jar 与 Java 应用程序包一起分发是否安全?

虽然tools.jar它不是 JRE 中的一个组件,但它附带了 JDK 的所有主要实现,例如 Oracle JDK 和 OpenJDK。

不是 JRE 的标准组件意味着当我分发使用 的 Java 应用程序时tools.jar,我必须将它与应用程序包一起分发或将其包含在类路径中。

我的问题是:

  • tools.jar 是否包含平台相关的组件,以防止它在不同平台(Windows/Linux/OSX)之间分布?
  • 我们已经知道 Oracle JDK 不允许分发tools.jar,但是 OpenJDK 呢,我们可以从 OpenJDK 分发 tools.jar 以避免许可问题吗?
  • 如果 tools.jar 不能与 Java 应用程序一起分发,是否有一种独立于平台的方法来确定其位置,以便将其放入类路径?

java openjdk jvm sun tools.jar

6
推荐指数
1
解决办法
2346
查看次数

如何使用aspectj-maven-plugin

我是AspectJ和Maven的新手.

我正在尝试使用aspectj-maven-plugin来构建我的项目,但它不起作用.我只是按照AspectJ In Action 2 nd Edition中的步骤进行操作.

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>aspectj-maven-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>compile</goal>
                        <goal>test-compile</goal>
                    </goals>

                    <configuration>
                        <source>1.5</source>
                        <target>1.5</target>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
Run Code Online (Sandbox Code Playgroud)

这是我<execution>在线上的错误消息:

生命周期配置未涵盖的插件执行:org.codehaus.mojo:aspectj-maven-plugin:1.4:compile(执行:默认,阶段:编译)

我正在使用JDK6和Apache Maven 3.0.4.

java aspectj maven

5
推荐指数
1
解决办法
9926
查看次数

如何使用sms lib api收发短信

我是 sms lib api 的新手,我以前从未使用过 api,请你给我一些帮助,如何从头到尾使用它在 eclipse 中使用 Gsm 调制解调器发送和接收短信。请这是紧急情况,我的最后一年的项目基于它。请这将是一个很大的帮助..提前谢谢

java smslib

0
推荐指数
1
解决办法
1万
查看次数