我想在下面提到的springApplicationContext.xml中保留编码密码
有没有办法实现这个目标?
目前我已使用property-placeholder配置了所有属性,如下所示,但原始密码仍在我的database.properties中打开
<beans:bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<beans:property name="driverClassName"><beans:value>${db.driverClassName}</beans:value></beans:property>
<beans:property name="url"><beans:value>${db.url}</beans:value></beans:property>
<beans:property name="username"><beans:value>${db.username}</beans:value></beans:property>
<beans:property name="password"><beans:value>${db.password}</beans:value></beans:property>
</beans:bean>
Run Code Online (Sandbox Code Playgroud)
但实际值存在于我的 database.properties
db.driverClassName=com.mysql.jdbc.Driver
db.url=jdbc:mysql://localhost/myDB
db.username=root
db.password=root
Run Code Online (Sandbox Code Playgroud)
我想要下面的东西:
<beans:bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<beans:property name="driverClassName"><beans:value>${db.driverClassName}</beans:value></beans:property>
<beans:property name="url"><beans:value>${db.url}</beans:value></beans:property>
<beans:property name="username"><beans:value>${db.username}</beans:value></beans:property>
<beans:property name="password"><beans:value>${db.password}</beans:value></beans:property>
</beans:bean>
Run Code Online (Sandbox Code Playgroud)
但是密码属性值应该是我的编目格式 database.properties
db.driverClassName=com.mysql.jdbc.Driver
db.url=jdbc:mysql://localhost/myDB
db.username=root
db.password=3g6n72ef8x (using any encription method).
Run Code Online (Sandbox Code Playgroud)
我的dataSource在进行新的数据库连接之前在内部解密密码.
非常感谢任何帮助/建议.
spring hibernate datasource password-encryption apache-commons-dbcp
我试图通过添加readResolve()方法编写Serializable Singleton类.我的目的是在序列化时获得与对象状态相同的对象.
下面是我的测试示例代码:
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
public class SingletonDemo {
public static void main(String[] args) {
Singleton obj = Singleton.getInstance();
System.out.println("After NEW Object creation : " + obj);
obj.i = 5;
System.out.println("Object modified");
System.out.println("After Object 1st Modification : " + obj);
serializeMe();
System.out.println("Serialized successfully with object state : " + obj);
obj.i = 10;
System.out.println("Object modified again");
System.out.println("After Object 2nd Modification : " + obj);
Singleton st = (Singleton)deSerializeMe(); …Run Code Online (Sandbox Code Playgroud) 我知道上面的问题很常见,但我只是想确切地知道 Hibernate 何时以及如何获取延迟加载的子记录。
下面是示例表结构:
employee_table(e_id, e_name, e_sal)
(100, XYZ, 20000)
mobile_table(m_id, m_number, e_id)
(1, 8728271817, 100)
(2, 0983813919, 100)
Run Code Online (Sandbox Code Playgroud)
public class Employee implements Serializable {
private static final long serialVersionUID = 1930751473454928876L;
private long employeeId;
private String employeeName;
private double employeeSal;
private Set<Mobile> mobiles;
public long getEmployeeId() {
return employeeId;
}
public void setEmployeeId(long employeeId) {
this.employeeId = employeeId;
}
public String getEmployeeName() {
return employeeName;
}
public void setEmployeeName(String employeeName) {
this.employeeName = employeeName;
}
public double …Run Code Online (Sandbox Code Playgroud) 我无法找到导致destroy-method我的应用程序在tomcat停止时关闭的原因.
我有一个Web应用程序,弹出上下文通过web.xml中的ContextLoaderListener加载,如下所示:
web.xml中
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:appContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
Run Code Online (Sandbox Code Playgroud)
下面是我的应用程序中的Employee bean:
Employee.class
public class Employee {
String eName;
long eSal;
public String getEName() {
return eName;
}
public void setEName(String name) {
eName = name;
}
public long getESal() {
return eSal;
}
public void setESal(long sal) {
eSal = sal;
}
public void init() {
System.out.println("Initiaizing...");
System.out.println("eName: " + eName + " - eSal: " + eSal);
}
public void close() {
System.out.println("Destroying...");
}
}
Run Code Online (Sandbox Code Playgroud)
并且bean在我的应用程序上下文文件中定义,如下所示: …
我正在使用中央身份验证系统(jasig.org)为我的Intranet Web应用程序实现单点登录功能.我在同一台机器(windows)中运行了两个tomcat实例.两个tomcat实例都已配置为使用SSL并使用了自签名sertificate(使用java keytool创建).
Cas Server.
<Connector port="8443" maxHttpHeaderSize="8192" SSLEnabled="true"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" disableUploadTimeout="true"
acceptCount="100" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"
keystoreFile="C:/Users/sandip.paul/.keystore"
keystorePass="changeit"
truststoreFile="C:/Program Files/Java/jdk1.6.0_20/jre/lib/security/cacerts" />
Run Code Online (Sandbox Code Playgroud)
myWebApp(使用spring security)
<Connector port="8663" maxHttpHeaderSize="8192" SSLEnabled="true"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" disableUploadTimeout="true"
acceptCount="100" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />
Run Code Online (Sandbox Code Playgroud)
下面是myWebApp的applicationContext-security.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:security="http://www.springframework.org/schema/security"
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-2.0.4.xsd">
<!--
Enable security, let the casAuthenticationEntryPoint handle all intercepted urls.
The CAS_FILTER needs to be in the right position within the filter chain. …Run Code Online (Sandbox Code Playgroud) 我正在寻找一些深入的解释Thread.start()内部如何调用run()方法.我知道它是我的JVM,它通过start()方法在内部调用run(),当我开始检查Thread类的源代码时,我发现以下代码:
public synchronized void start()
{
if(threadStatus != 0)
throw new IllegalThreadStateException();
group.add(this);
start0();
if(stopBeforeStart)
stop0(throwableFromStop);
}
private native void start0();
Run Code Online (Sandbox Code Playgroud)
现在我可以看到start()调用本机方法start0()但我看不到任何与加载本机代码库相关的代码.
请帮我理解完整的呼叫流程.
谢谢,Sandip
我正面临着时区问题.让我试着描述:
我的Web应用程序和数据库运行在具有与当地时区(印度/加尔各答即UTC + 5:30)不同的时区(欧洲/马德里,即UTC + 1)的服务器上.
假设我当地的当前时间是:2014年1月15日星期三14:35:00,服务器当前时间是:2014年1月15日星期三10:05:00 CET,即延迟4:30.
现在,当我尝试使用我的网页(GUI)中的日历选择来保存数据库上的日期时间时,我所选择的日期时间是:Wed Jan 15 18:30:00,即将保存的最终日期在DB正在成为1月15日星期三14:00:00(看到差异正好是4:30小时滞后时间).
让我告诉你上面流程的编码部分.
从我的网页日历中选择 - >将所选日期时间的时间戳(长)传递给我的服务器端控制器 - >在服务器端,我正在构建java.util.Date对象并保存到DB,如下所示:
java.util.Date newDt = new java.util.Date(timeStampInMillis);
Run Code Online (Sandbox Code Playgroud)
这里,timeStampInMillis是long,我从GUI中选择的日期时间转换而来.
这里它将该服务器的当前时区(UTC + 01:00)中的给定时间戳保存,这就是保存的日期时间如何滞后4:30小时.
但我想保存,因为它是从日历GUI中选择的日期时间.
我有一些解决方案,比如在我的服务器端控制器中传递构造Date对象的时间戳,我可以从我的日历GUI传递所选日期时间的String表示,然后解析格式并保存到DB中.
但我想知道我是否可以使用Timezone API做任何事情.
希望我的问题对你很清楚.如果没有,请澄清您的疑问.
需要你的帮助...
谢谢.