小编Ger*_*ger的帖子

Sql Server - 使用Windows身份验证连接

我必须使用Windows身份验证连接到SQL Server

sql server在机器上192.168.3.6 web服务器(客户端)在我的机器192.168.3.10上

我正在使用JTDS驱动程序

dbUrl=jdbc:jtds:sqlserver://192.168.3.6:1099/db_test;instance=test
Connection con = DriverManager.getConnection( dbUrl, "", "" );
Run Code Online (Sandbox Code Playgroud)

我有sql server管理员用户的用户名和密码!

我也投入ntlmauth.dllc:\windows,c:\windows\system32而且我总是错误:

java.sql.SQLException:用户'(null)'登录失败.原因:与受信任的SQL Server连接无关.

有什么想法解决我的问题吗?非常感谢你

sql-server jdbc

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

可选的@PropertySource位置

我在Web应用程序中使用Spring 3.2,我想.properties在类路径中包含一个包含默认值的文件.用户应该能够使用JNDI定义.properties存储另一个的位置,该位置将覆盖默认值.

只要用户设置了configLocationJNDI属性,以下内容就可以正常工作.

@Configuration
@PropertySource({ "classpath:default.properties", "file:${java:comp/env/configLocation}/override.properties" })
public class AppConfig
{
}
Run Code Online (Sandbox Code Playgroud)

但是,外部覆盖应该是可选的,JNDI属性也应该是可选的.

目前我得到一个例外(java.io.FileNotFoundException: comp\env\configLocation\app.properties (The system cannot find the path specified)当JNDI属性丢失时).

如何定义.properties仅在设置JNDI属性(configLocation)时使用的可选项?这是否可能@PropertySource或有其他解决方案?

java spring spring-annotations

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

使用每个密钥的行号加载YAML

假设我有一个YAML文件,如下所示:

  en:
    errors:
      # Some comment
      format: "%{attribute} %{message}"

      # One more comment
      messages:
        "1": "Message 1"
        "2": "Message 2"

    long_error_message: |
      This is a
      multiline message

    date:
      format: "YYYY-MM-DD"

我怎么能把这个读Hash成像这样的Ruby ?

{
  'en': {
    'errors': {
      'format': { value: '%{attribute} %{message}', line: 4 }
      'messages': {
        '1': { value: 'Message 1', line: 8 },
        '2': { value: 'Message 2', line: 9 }
      }
      'long_error_message' : { value: "This is a\nmultiline message", line: 11 }
    },
    'date': { …
Run Code Online (Sandbox Code Playgroud)

ruby yaml

8
推荐指数
1
解决办法
1295
查看次数

Gradle忽略传递依赖

我正在尝试使用Flex库(SWC),它在其POM中定义了一些依赖项.我希望Gradle会自动提供那些传递性的依赖性.但是,gradle dependencies仅显示已手动添加的一个依赖项.

merged
\--- com.example:flex-core:1.0.0
Run Code Online (Sandbox Code Playgroud)

该库的POM文件包含以下内容:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.example</groupId>
  <artifactId>flex-core</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <packaging>swc</packaging>
  <dependencies>
    <dependency>
      <groupId>org.as3commons</groupId>
      <artifactId>as3commons-lang</artifactId>
      <version>0.3.6</version>
      <type>swc</type>
      <scope>external</scope>
    </dependency>
    <dependency>
      <groupId>org.as3commons</groupId>
      <artifactId>as3commons-collections</artifactId>
      <version>1.3.2</version>
      <type>swc</type>
      <scope>external</scope>
    </dependency>
    <dependency>
      <groupId>org.as3commons</groupId>
      <artifactId>as3commons-reflect</artifactId>
      <version>1.6.0</version>
      <type>swc</type>
      <scope>external</scope>
    </dependency>
  </dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)

我在我的添加中添加了以下依赖项build.gradle:

dependencies {
    merged 'com.example:flex-core:1.0.0@swc'
}
Run Code Online (Sandbox Code Playgroud)

为什么Gradle忽略了POM的依赖关系?是因为"外部"范围?是否可以在不手动添加依赖项的情况下获取这些依赖项?

gradle gradlefx

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

在Java中的return语句中递减(或递增)运算符

我在我的Web应用程序(使用Spring和Hibernate)中实现了分页,我需要的东西类似于以下内容.

public static int deleteSingle(long totalRows, long pageSize, int currentPage)
{
   return totalRows==currentPage*pageSize-pageSize ? currentPage-- : currentPage;
}
Run Code Online (Sandbox Code Playgroud)

假设,我从以下某处调用此方法.

deleteSingle(24, 2, 13);
Run Code Online (Sandbox Code Playgroud)

使用这些参数,条件得到满足,并且currentPage应该返回变量(即13)减去1(即12)的值,但不会递减值currentPage.它返回此调用后的原始值13.


我必须像下面这样更改方法,以使其按预期工作.

public static int deleteSingle(long totalRows, long pageSize, int currentPage)
{
    if(totalRows==currentPage*pageSize-pageSize)
    {
        currentPage=currentPage-1;   //<-------
        return currentPage;          //<-------
    }
    else
    {
        return currentPage;
    }
}
Run Code Online (Sandbox Code Playgroud)

那么为什么不用减量运算符将值减1 currentPage--呢?为什么需要 - currentPage=currentPage-1;在这种情况下?

java

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

标签 统计

java ×2

gradle ×1

gradlefx ×1

jdbc ×1

ruby ×1

spring ×1

spring-annotations ×1

sql-server ×1

yaml ×1