小编TIM*_*NNY的帖子

为什么使用JndiObjectFactoryBean配置JNDI数据源不起作用?

当我使用基于Java的Java配置我的JNDI时。春天4.2.5。

但是,如果我使用JndiObjectFactoryBean进行配置。当我想获取时datasource,该对象将为null。

@Bean
    public DataSource dataSource(){
        JndiObjectFactoryBean jndiObjectFactoryBean =new JndiObjectFactoryBean();
        jndiObjectFactoryBean.setJndiName("jdbc/SpittrDS");
        jndiObjectFactoryBean.setResourceRef(true);
        jndiObjectFactoryBean.setProxyInterface(DataSource.class);
        return (DataSource) jndiObjectFactoryBean.getObject();  //NULL!!!
    }
Run Code Online (Sandbox Code Playgroud)

但是如果对此更改方法,它将很好地工作。

@Bean
    public DataSource dataSource(){
        final JndiDataSourceLookup dsLookup = new JndiDataSourceLookup();
        dsLookup.setResourceRef(true);
        DataSource dataSource = dsLookup.getDataSource("java:comp/env/jdbc/SpittrDS");
        return dataSource;
    }
Run Code Online (Sandbox Code Playgroud)

我不知道问题出在哪里。

Tomcat 9.0 context.xml

<Context>

    <!-- Default set of monitored resources. If one of these changes, the    -->
    <!-- web application will be reloaded.                                   -->
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
    <WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>

    <!-- Uncomment this to disable session persistence across Tomcat restarts -->
    <!--
    <Manager pathname="" …
Run Code Online (Sandbox Code Playgroud)

java spring jndi

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

org.gradle.process.internal.ExecException: Process '命令以非零退出值 1 完成

例外

> Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'D:\Java\jdk1.8.0_45\bin\java.exe'' finished with non-zero exit value 1
Run Code Online (Sandbox Code Playgroud)

控制台日志

> FAILURE: Build failed with an exception.

>  * What went wrong:
Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command >'D:\Java\jdk1.8.0_45\bin\java.exe'' finished with non-zero exit value 1

>* Try:
>Run with --info or --debug option to get more log output.

> * Exception is:
> org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:dexDebug'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
    at …
Run Code Online (Sandbox Code Playgroud)

java android android-studio

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

Android工作室,当我在应用程序中添加Java模块时,这将是错误的

当我使用这个'依赖'时,一切都很好.该应用运行.

应用程序依赖项:

dependencies {

    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'com.android.support:design:23.0.1'
    compile 'com.android.support:recyclerview-v7:23.0.1'
    compile 'org.jsoup:jsoup:1.7.2'
    compile 'com.mcxiaoke.volley:library:1.0.19'
}
Run Code Online (Sandbox Code Playgroud)

但是当我在这个应用程序中添加一个java模块依赖项时,它会抛出错误:

错误:任务':app:dexDebug'的执行失败.com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:进程'命令'D:\ Java\jdk1.8.0_45\bin\java.exe''以非零退出值结束1

像这样

    apply plugin: 'com.android.application'

    android {
        compileSdkVersion 23
        buildToolsVersion "23.0.1"

        defaultConfig {
            applicationId "three.com.materialdesignexample"
            minSdkVersion 15
            targetSdkVersion 23
            versionCode 1
            versionName "1.0"
            multiDexEnabled true
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }

    }

    dependencies {

        compile project(':securitycode')
        compile 'com.android.support:appcompat-v7:23.0.1'
        compile 'com.android.support:design:23.0.1'
        compile 'com.android.support:recyclerview-v7:23.0.1'
        compile 'org.jsoup:jsoup:1.7.2'
        compile 'com.mcxiaoke.volley:library:1.0.19'
    }
Run Code Online (Sandbox Code Playgroud)

我的Java模块依赖项什么都没有

apply plugin: 'java'

dependencies { …
Run Code Online (Sandbox Code Playgroud)

android android-studio

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

标签 统计

android ×2

android-studio ×2

java ×2

jndi ×1

spring ×1