标签: configuration

Spring控制台应用程序,从JAR外部加载属性文件

我在控制台Java应用程序中使用Spring.我的应用程序将部署如下:

folder/myJar.jar
folder/db/connection.properties
Run Code Online (Sandbox Code Playgroud)

如何加载connection.propertiesPropertyPlaceholderConfigurer应用方面?

我试过了

<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location" value="db/connection.properties"/>
</bean>
Run Code Online (Sandbox Code Playgroud)

但它不会起作用.

我需要这种方式来获取我的数据库用户名/密码和其他详细信息.

java configuration spring

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

访问App.config

我在我的App.config中有以下内容,如何使其下面的代码工作????

configuration>
    <configSections>
    </configSections>
    <connectionStrings>
        <add name="WpfDatabind3.Properties.Settings.cbfSQL1ConnectionString"
            connectionString="Data Source=STEPHANS-PC\SQLEXPRESS;Initial Catalog=cbfSQL1;Integrated Security=True"
            providerName="System.Data.SqlClient" />
    </connectionStrings>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
</configuration>
Run Code Online (Sandbox Code Playgroud)

我无法弄清楚如何访问App.config中的连接字符串.

DataSet myDataSet;

private void OnInit(object sender, EventArgs e)
{
  string mdbFile = Path.Combine(AppDataPath, "BookData.mdb");
  string connString = string.Format(
      "Provider=Microsoft.Jet.OLEDB.4.0; Data Source={0}", mdbFile);
  OleDbConnection conn = new OleDbConnection(connString);
  OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM BookTable;", conn);

  myDataSet = new DataSet();
  adapter.Fill(myDataSet, "BookTable");

  // myListBox is a ListBox control. 
  // Set the DataContext of the ListBox to myDataSet
  myListBox.DataContext …
Run Code Online (Sandbox Code Playgroud)

c# configuration connection-string app-config

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

尝试运行doctrine命令时"em未定义错误"

我刚刚设置了一个ZF2项目并为Doctrine2配置了所有项目而没有问题.它工作,现在只是给我一个错误,因为它找不到我想要查询的数据库表.

实体也正确设置,全部按照http://www.jasongrimes.org/2012/01/using-doctrine-2-in-zend-framework-2/

所以想使用CLI来创建表等,但是在运行任何CLI命令时我都会得到

[InvalidArgumentException]       
The helper "em" is not defined.
Run Code Online (Sandbox Code Playgroud)

我正在使用的命令

php doctrine.php orm:schema-tool:update --dump-sql
Run Code Online (Sandbox Code Playgroud)

我从文件夹运行doctrine.php

/Library/WebServer/Documents/zf2-Skel-NewProj1/vendor/bin
Run Code Online (Sandbox Code Playgroud)

现在,如果我将CLI用于我的一个ZF1.11项目,它可以正常工作.

为了实现这一点,我必须编辑位于其下的cli-config.php文件

/Library/WebServer/Documents/zf2-Skel-NewProj1/vendor/doctrine/orm/tools
Run Code Online (Sandbox Code Playgroud)

该文件的内容是:

<?php

require_once '../../lib/vendor/doctrine-common/lib/Doctrine/Common/ClassLoader.php';

$classLoader = new \Doctrine\Common\ClassLoader('Doctrine\ORM', realpath(__DIR__ . '/../../lib'));
$classLoader->register();
$classLoader = new \Doctrine\Common\ClassLoader('Doctrine\DBAL', realpath(__DIR__ . '/../../lib/vendor/doctrine-dbal/lib'));
$classLoader->register();
$classLoader = new \Doctrine\Common\ClassLoader('Doctrine\Common', realpath(__DIR__ . '/../../lib/vendor/doctrine-common/lib'));
$classLoader->register();
$classLoader = new \Doctrine\Common\ClassLoader('Symfony', realpath(__DIR__ . '/../../lib/vendor'));
$classLoader->register();
$classLoader = new \Doctrine\Common\ClassLoader('Entities', __DIR__);
$classLoader->register();
$classLoader = new \Doctrine\Common\ClassLoader('Proxies', __DIR__);
$classLoader->register();

$config = new \Doctrine\ORM\Configuration();
$config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache);
$driverImpl = $config->newDefaultAnnotationDriver(array(__DIR__."/Entities"));
$config->setMetadataDriverImpl($driverImpl);

$config->setProxyDir(__DIR__ …
Run Code Online (Sandbox Code Playgroud)

configuration zend-framework command-line-interface doctrine-orm

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

使用H2数据库时,sonar-runner.bat会出现问题

我从声纳网站下载声纳-3.5.1.我设置了sonar.properties数据库,如下所示:

sonar.jdbc.username:                       sonar
sonar.jdbc.password:                       sonar
sonar.jdbc.url:                            jdbc:h2:tcp://localhost:9092/sonar
sonar.jdbc.driverClassName:                org.h2.Driver
sonar.embeddedDatabase.port:               9092
Run Code Online (Sandbox Code Playgroud)

然后我将声纳部署到Tomcat.我可以从中浏览它http://xxzjjc:8080/sonar.然后我开始运行analyze sonar-runner.bat.但发生错误:

ERROR: Error during Sonar runner execution
ERROR: Unable to execute Sonar
ERROR: Caused by: Fail to connect to database
ERROR: Caused by: Cannot load JDBC driver class 'net.sourceforge.jtds.jdbc.Driver'
ERROR: Caused by: net.sourceforge.jtds.jdbc.Driver
Run Code Online (Sandbox Code Playgroud)

我试了一天,不幸的是,我没有找到任何东西.任何人都可以给我一个解决方案吗?非常感谢你!

configuration sonarqube

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

requireJS将配置信息传递给所有带"*"通配符的模块

我需要使用requireJS将配置值传递到我的所有AMD模块中.

通过使用以下示例,我可以愉快地将配置值传递给特定模块; 如requireJS API配置模块文档中所述

requirejs.config({
    config: {
        'bar': {
            raw: true
        },
        'baz': {
            raw: true
        },
        ...
    }
});
Run Code Online (Sandbox Code Playgroud)

以上工作正常,但我有50个模块,我想传递相同的配置值,这些可能会增加或改变.我可以定义50个模块名称,如上所述,并传递值,但我真的不想按名称定义每个模块并维护该列表,而是我想做这样的事情.

requirejs.config({
    config: {
        '*': {
            raw: true
        }
    }
});
Run Code Online (Sandbox Code Playgroud)

我已经尝试过以上但是没有用.

requireJS配置映射似乎支持"*"通配符,但我没有看到任何类似的"配置".我已经搜索过了,但我想我的搜索日期很糟糕.

所以,问题是:"config"是否有"*"通配符支持,我只是遇到了问题?或者还有其他方法可以实现这一目标吗?

javascript configuration amd requirejs

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

Spring-JPA-Hibernate配置:设置属性hiberate.hbm2dll.auto创建无效?

我有这个配置问题:

1)我有jpaPropertyMap,属性hibernate.hbm2dll.auto设置为create但它没有效果.它没有创建表生成SQL.

我可以在日志文件中看到其他jpaPropertyMap属性,如dialect得到正确设置,因此正在读取属性映射.

2)如果我将HibernateJpaVendorAdapter的属性generateddl设置为true,则生成表.

那么为什么hibernate.hbm2dll.auto不能在case/generate表中工作呢.

这是配置文件:

<?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:context="http://www.springframework.org/schema/context"
    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.2.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd">

    <context:annotation-config />
    <context:component-scan base-package="org.demoapps.placementwebsite"/>

    <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />

    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
        <property name="url" value="jdbc:mysql://localhost:3306/cpm?autoReconnect=true" />
        <property name="username" value="user" />
        <property name="password" value="password" />
    </bean>

    <bean id="entityManagerFactory"
        class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="persistenceUnitName" value="punit" />
        <property name="dataSource" ref="dataSource" />
        <property name="jpaVendorAdapter">
            <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                <property name="showSql" value="true" />
            </bean>
        </property>

        <property name="jpaPropertyMap">
            <map>
                <entry key="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
                <entry key="hibernate.hbm2dll.auto" value="create"/>
                <entry key="hibernate.format_sql" value="true" …
Run Code Online (Sandbox Code Playgroud)

configuration spring hibernate jpa

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

在jobtracker上有hadoop conf/masters和conf/slaves?

在一个hadoop集群(1.x版本)中,NameNode和JobTracker不是同一个服务器,是否需要在NameNode和JobTracker上或仅在NameNode上指定conf/masters和conf/slaves?我似乎无法在文档中找到对此的直接答案.

configuration hadoop

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

设置Java/Tomcat堆大小(Xmx)而不修改catalina.sh

大多数人似乎建议通过编辑/usr/share/tomcat6/bin/catalina.sh文件为Tomcat6设置Java/Tomcat堆内存大小,并添加如下内容:

# Set specific memory requirements for Tomcat6 (for server with ~512MB RAM).
CATALINA_OPTS="$CATALINA_OPTS -server -Xms128m -Xmx256m"
Run Code Online (Sandbox Code Playgroud)

我正在尝试构建一个Ansible playbook来在Ubuntu上配置基于Tomcat的服务器,而且我似乎不喜欢整个自定义catalina.sh文件是理想的 - 是否有一些其他配置文件或本地设置文件/ Tomcat和/或Java用来获取XmsXmx值的系统?

或者......大多数人都使用自定义的catalina.sh文件,而我只是在一个小山丘上建造一座山?

java heap configuration tomcat

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

CMS块中的Magento Config变量带有断行

我想在Magento网站上的CMS Block中使用商店地址,但问题是换行符没有使用以下格式:

{{config path="general/store_information/address"}}
Run Code Online (Sandbox Code Playgroud)

以前在我们使用过的模板中:

nl2br(Mage::getStoreConfig('general/store_information/address'));
Run Code Online (Sandbox Code Playgroud)

以上工作正常,但我们想摆脱模板限制.

有没有可能的方法在配置变量在CMS块中提取时添加换行符/格式.在配置中,输入地址并带有换行符.

configuration static-block magento

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

Spring Boot @RestController拒绝POST请求

POST请求

http:// localhost:9278 / submitEnrollment

封装外部SOAP调用的Spring Boot应用程序执行以下操作:

{
  "timestamp": 1439480941381,
  "status": 401,
  "error": "Unauthorized",
  "message": "Full authentication is required to access this resource",
  "path": "/submitEnrollment"
}
Run Code Online (Sandbox Code Playgroud)

这似乎不是正常现象,我想知道我需要放松/禁用哪些Spring Boot配置才能阻止此客户端身份验证。

以下是相关的代码段:

应用程序的配置(需要通过SSL发送安全的SOAP调用所需的所有必要操作,并会影响网络层):

    @Configuration
@ComponentScan({"a.b.c.d", "com.submit.enrollment"})
@PropertySource("classpath:/submit-enrollment.properties")
public class SubmitEnrollmentConfig {

    @Value("${marshaller.contextPaths}")
    private String[] marshallerContextPaths;

    @Value("${default.Uri}")
    private String defaultUri;

    @Bean
    public FfmSoapClient connectivityClient() throws Throwable {
        FfmSoapClient client = new FfmSoapClient();
        client.setWebServiceTemplate(webServiceTemplate());
        return client;
    }

    @Bean
    public KeyStore keyStore() throws Throwable {
        KeyStoreFactoryBean keyStoreFactory = new KeyStoreFactoryBean();
        keyStoreFactory.setPassword("!zxy!36!");
        keyStoreFactory.setLocation(new ClassPathResource("zxy.jks"));
        keyStoreFactory.setType("jks");
        keyStoreFactory.afterPropertiesSet();
        return …
Run Code Online (Sandbox Code Playgroud)

security configuration web spring-boot spring-restcontroller

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