小编use*_*796的帖子

动态地将属性注入弹簧中

我有一个spring config xml文件,它可以创建多个bean并将其自动装配到其他bean中

例如

<bean id="a" class="com.xyz.A">
        <property name="prop1" value="?" />
   </bean>

   <bean id="b" class="com.xyz.B">
        <property name="prop2" ref="a" />   
   </bean>
Run Code Online (Sandbox Code Playgroud)

我通过阅读上面的spring文件来创建应用程序上下文.但是A的prop1的值在运行时是动态已知的.如何动态注入此属性?动态我的意思是应用程序启动时.例如,一些属性作为命令行输入到应用程序.然后应将此属性设置为bean的属性

我已经给出了这个例子来简化问题.真正的我的动态参数是数据库服务器url,我想动态创建连接池

java spring dependency-injection

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

声音在Android版本大于4.0时无法播放

我正在使用以下代码在我的应用程序中播放声音.在ICS之前一切正常.但是在ICS和更新的版本上,虽然没有出现错误,但听不到声音.

编辑:注意,以下代码由广泛的接收器触发.BroadCast接收器调用异步任务.在asycn任务的后处理方法中,调用以下方法.

此错误仅在特定的移动型号(例如nexus)上发生,并且在某些型号上,用户可以播放声音,这些声音与库存操作系统有关,但不是他们在rigtones文件夹中放置的声音.

我不知道特定手机上发生的问题是什么

错误可能是什么?

public static void playSound(final Context context, final int volume,
            Uri uri, final int stream, int maxTime, int tickTime) {
        //stopPlaying();
        /*
        if (stream < 0 || stream > 100) {
            throw new IllegalArgumentException(
                    "volume must be between 0 and 100 .Current volume "
                            + volume);
        }*/

        final AudioManager mAudioManager = (AudioManager) context
                .getSystemService(Context.AUDIO_SERVICE);

        int deviceLocalVolume = getDeviceVolume(volume,
                mAudioManager.getStreamMaxVolume(stream));

        Log.d(TAG,
                "device max volume = "
                        + mAudioManager.getStreamMaxVolume(stream)
                        + " for streamType " + stream);
        Log.d(TAG, …
Run Code Online (Sandbox Code Playgroud)

android soundpool android-mediaplayer

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

用Java发送电子邮件?

任何人都可以建议使用Java发送电子邮件的库吗?

java email

4
推荐指数
3
解决办法
3396
查看次数

如何获得weka集群质心的价值

我正在使用weka kmeans分类器,我已经建立了一个模型.现在我想要聚集每个质心的中心值.我在weka UI上得到它

Attribute    Full Data          0          1
               (48836)    (39469)     (9367)
============================================
tt            428.6238   514.1345    68.3143
Run Code Online (Sandbox Code Playgroud)

我如何使用weka java jar获取它?

我的weka集群训练集只有一个属性.

要获取属性名称,请执行以下操作:String attname = clusterCenters.get(0).attribute(0).name();

如何获得集群中心的价值?

java weka k-means

4
推荐指数
1
解决办法
4662
查看次数

警告:在带有名称的DispatcherServlet中,找不到带有URI []的HTTP请求的映射

我有我的web.xml

<context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext.xml</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>2</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
Run Code Online (Sandbox Code Playgroud)

applicationContext as

<?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:p="http://www.springframework.org/schema/p"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd"
>

    <context:component-scan base-package="com.mindedges" />


</beans>
Run Code Online (Sandbox Code Playgroud)

Dispatcher servlet as

    <?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:p="http://www.springframework.org/schema/p"
           xmlns:aop="http://www.springframework.org/schema/aop"
           xmlns:tx="http://www.springframework.org/schema/tx"
           xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">

        <bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/>

        <!--
        Most controllers will use the ControllerClassNameHandlerMapping above, but
        for the index controller we are using ParameterizableViewController, so …
Run Code Online (Sandbox Code Playgroud)

java spring spring-mvc

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

确定我网站访问者的国家/地区

我想确定我的访客来自使用php的国家.我怎样才能做到这一点?

php geolocation

3
推荐指数
1
解决办法
2343
查看次数

通过仅考虑属性=值的顶点来查找2个顶点之间的所有路径

我有一个遍历用例如下.orientDb支持它吗?

1)找到从node1到node2的所有路径.只切换那些具有属性xyz ="val1"的节点2)找到最短路径.ONLY TRAVERSE那些具有属性xyz ="val1"的节点3)找到最长路径.ONLY TRAVERSE那些节点它有属性xyz ="val1"

abstract class TraversGraph{
     public  Path getPath(Node src,Node dest, Propery property,Value value);
}
Run Code Online (Sandbox Code Playgroud)

注意:请注意我在上限中提到的情况

orientdb gremlin

3
推荐指数
1
解决办法
2701
查看次数

错误:java.io.IOException:错误的值类:类org.apache.hadoop.io.Text不是类Myclass

我有我的mapper和reducer如下.但我得到了一些奇怪的例外.我无法弄清楚为什么会抛出这种异常.

public static class MyMapper implements Mapper<LongWritable, Text, Text, Info> {

    @Override
    public void map(LongWritable key, Text value,
        OutputCollector<Text, Info> output, Reporter reporter)
        throws IOException {
        Text text = new Text("someText")
            //process 
        output.collect(text, infoObjeject);
    }

}

public static class MyReducer implements Reducer<Text, Info, Text, Text> {

    @Override
    public void reduce(Text key, Iterator<Info> values,
        OutputCollector<Text, Text> output, Reporter reporter)
        throws IOException {
        String value = "xyz" //derived in some way
        //process
        output.collect(key, new Text(value)); //exception occurs at this line
    }

} …
Run Code Online (Sandbox Code Playgroud)

java hadoop elastic-map-reduce

3
推荐指数
1
解决办法
3678
查看次数

在php中识别服务器端的浏览器

我有一个网站.当用户点击特定页面(比如identify.php)时,我想找到客户端正在使用的浏览器类型.浏览器可能是mozilla,IE,opera,chrome或任何其他移动设备,如SonyEricssonK610i,SAMSUNG-SGH-E370,SonyEricssonT700或NokiaN73-1.

这可以检测用户浏览器吗?

php browser mobile

2
推荐指数
1
解决办法
1601
查看次数

用PHP发送带附件的电子邮件?

如何使用PHP脚本发送带附件的电子邮件?

php email

2
推荐指数
1
解决办法
1436
查看次数