我想转换java.time.LocalDate成java.util.Date类型.因为我想将日期设置为JDateChooser.或者是否有支持java.time日期的日期选择器?
我在Question实体中有以下内容:
@NamedQuery(name = "Question.allApproved",
query = "SELECT q FROM Question q WHERE q.status = 'APPROVED'")
Run Code Online (Sandbox Code Playgroud)
和
@Enumerated(EnumType.STRING)
private Status status;
// usual accessors
Run Code Online (Sandbox Code Playgroud)
我得到这个例外:
异常说明:编译查询时出错[Question.countApproved:
SELECT COUNT(q) FROM Question q WHERE q.status = 'APPROVED'],第1行,第47列:无效的枚举等于表达式,无法将类型[myCompnay.application.Status]的枚举值与非枚举值类型进行比较[java.lang.String].at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:501)
我该如何解决?
我正在设置Spring Security来处理日志记录用户.我已经以用户身份登录,并在成功登录后被带到Access Denied错误页面.我不知道我的用户实际分配了什么角色,或者导致访问被拒绝的规则,因为我无法弄清楚如何为Spring Security库启用调试.
我的安全xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans ... >
<!-- security -->
<security:debug/><!-- doesn't seem to be working -->
<security:http auto-config="true">
<security:intercept-url pattern="/Admin**" access="hasRole('PROGRAMMER') or hasRole('ADMIN')"/>
<security:form-login login-page="/Load.do"
default-target-url="/Admin.do?m=loadAdminMain"
authentication-failure-url="/Load.do?error=true"
username-parameter="j_username"
password-parameter="j_password"
login-processing-url="/j_spring_security_check"/>
<security:csrf/><!-- enable Cross Site Request Forgery protection -->
</security:http>
<security:authentication-manager>
<security:authentication-provider>
<security:jdbc-user-service data-source-ref="loginDataSource"
users-by-username-query="SELECT username, password, active FROM userinformation WHERE username = ?"
authorities-by-username-query="
SELECT ui.username, r.rolename
FROM role r, userrole ur, userinformation ui
WHERE ui.username=?
AND ui.userinformationid = ur.userinformationid
AND ur.roleid = r.roleid " …Run Code Online (Sandbox Code Playgroud) 对于单元测试(如果需要,可以调用它们进行集成测试)我在Spring配置中配置了一个嵌入式数据库,如下所示:
<jdbc:embedded-database id="dataSource" type="H2">
<jdbc:script location="classpath:schema_h2.sql" />
</jdbc:embedded-database>
Run Code Online (Sandbox Code Playgroud)
现在,当从命令行运行测试时,它们工作正常,但最后我得到了一些错误(无害,但令人恼火):
WARN 2013-03-25 12:20:22,656 [Thread-9] o.s.j.d.e.H2EmbeddedDatabaseConfigurer 'Could not shutdown embedded database'
org.h2.jdbc.JdbcSQLException: Database is already closed (to disable automatic closing at VM shutdown, add ";DB_CLOSE_ON_EXIT=FALSE" to the db URL) [90121-170]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:329) ~[h2-1.3.170.jar:1.3.170]
...
at org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactoryBean.destroy(EmbeddedDatabaseFactoryBean.java:65) [spring-jdbc-3.2.1.RELEASE.jar:3.2.1.RELEASE]
at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:238) [spring-beans-3.2.1.RELEASE.jar:3.2.1.RELEASE]
Run Code Online (Sandbox Code Playgroud)
现在,异常中包含的提示一般很好,但是如何将此属性添加到嵌入式数据源?我是否必须扩展它,手动配置它可以说,添加这样的"高级"功能?
我在Struts 2 + Spring IOC项目中使用Spring Security 3.
我在我的项目中使用过滤器,身份验证提供程序等.
你可以在这里看到我的security.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1.xsd">
<global-method-security pre-post-annotations="enabled">
<expression-handler ref="expressionHandler" />
</global-method-security>
<beans:bean id="expressionHandler"
class="org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler" >
<beans:property name="permissionEvaluator" ref="customPermissionEvaluator" />
</beans:bean>
<beans:bean class="code.permission.MyCustomPermissionEvaluator" id="customPermissionEvaluator" />
<!-- User Login -->
<http auto-config="true" use-expressions="true" pattern="/user/*" >
<intercept-url pattern="/index.jsp" access="permitAll"/>
<intercept-url pattern="/user/showLoginPage.action" access="permitAll"/>
<intercept-url pattern="/user/showFirstPage" access="hasRole('ROLE_USER') or hasRole('ROLE_VISIT')"/>
<intercept-url pattern="/user/showSecondUserPage" access="hasRole('ROLE_USER')"/>
<intercept-url pattern="/user/showThirdUserPage" access="hasRole('ROLE_VISIT')"/>
<intercept-url pattern="/user/showFirstPage" access="hasRole('ROLE_USER') or hasRole('ROLE_VISIT')"/>
<form-login login-page="/user/showLoginPage.action" />
<logout invalidate-session="true"
logout-success-url="/"
logout-url="/user/j_spring_security_logout"/>
<access-denied-handler ref="myAccessDeniedHandler" …Run Code Online (Sandbox Code Playgroud) 我在Spring Boot应用程序中的Logback配置有问题.我希望我consoleAppender看起来像默认的Spring Boot控制台appender.如何从Spring Boot默认控制台appender继承模式?
以下是我的consoleAppender配置
<appender name="consoleAppender" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern class="org.">
%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n
</Pattern>
</layout>
</appender>
Run Code Online (Sandbox Code Playgroud) 如何@Lock为查询指定超时.我正在使用oracle 11g,我希望我可以使用类似的东西'select id from table where id = ?1 for update wait 5'.
我定义了这样的方法,
@Lock(LockModeType.PESSIMISTIC_WRITE)
Stock findById(String id);
Run Code Online (Sandbox Code Playgroud)
它似乎永远锁定.我开始javax.persistence.lock.timeout=0了LocalContainerEntityManagerFactoryBean.jpaProperties,但没有受到影响.
在开始我的应用程序时,我会收到大量警告o.s.aop.framework.Cglib2AopProxy 'Unable to proxy method [public final void org.springframework.jdbc.core.support.JdbcDaoSupport.setDataSource(javax.sql.DataSource)] because it is final: All calls to this method via a proxy will be routed directly to the proxy.',大约有十几个功能.
现在我完全理解基于代理的方面不能应用于最终方法.但是,我没有(至少是故意的)尝试编织任何方面JdbcDaoSupport.我怀疑它来自<tx:annotation-driven />.我能做些什么来消除这些警告,或者更好的是,将这些类别排除在编织方面?
我试图在一个小型独立应用程序中一起使用spring数据和spring配置.
...
public static void main( String[] args )
{
ApplicationContext ctx = new AnnotationConfigApplicationContext(AppConfig.class);
...
}
Run Code Online (Sandbox Code Playgroud)
1.我的问题是如何在不使用的情况下发现spring数据存储库
<jpa:repositories base-package="foo.repositories" />
Run Code Online (Sandbox Code Playgroud)
通过spring config?
2.如果没有,我可以以某种方式一起使用'ClassPathXmlApplicationContext'和'AnnotationConfigApplicationContext'吗?
如果我有以下配置:
<defaultCache timeToIdleSeconds="120"
timeToLiveSeconds="120" />
<cache name="test"
timeToLiveSeconds="300" />
Run Code Online (Sandbox Code Playgroud)
timeToIdleSeconds缓存的价值是test什么?它是继承自默认缓存,因此等于120,还是采用手册中给出的默认值,即0(无穷大)?
spring ×6
java ×5
jpa ×2
debugging ×1
ehcache ×1
h2 ×1
hibernate ×1
java-8 ×1
java-ee ×1
java-time ×1
logback ×1
oracle ×1
spring-aop ×1
spring-boot ×1
spring-data ×1