小编ale*_*xbt的帖子

使用批处理文件注册dll和ocx文件

我在c dirve上的文件夹上有dll和ocx文件,只想通过单击批处理文件进行注册

windows windows-xp

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

将404错误页面重定向到Tomcat中我的Spring MVC webapp的自定义页面

我正在使用tomcat 7,我已经在tomcat 7中构建并部署了一个Spring MVC webapp,它的工作非常好.我想要的是,每当我的服务器上发生404错误时,它应该被重定向到我在webapp中构建的自定义页面.我已将我的webapp配置为tomcat中的默认webapp.

我试过这样做:

<error-page>
    <error-code>404</error-code>
    <location>/WEB-INF/templates/error/error.html</location>
</error-page>
Run Code Online (Sandbox Code Playgroud)

但一切都是徒劳的.

很高兴,如果有人可以帮我解决这个问题.

java spring-mvc tomcat7

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

Spring + hibernate java.lang.StackOverflowError

我是Hibernate的新手并面临这个问题:

@Transactional(readOnly=true)
@Override
public List<User> fetchListUsers() {

    return sessionFactory.getCurrentSession().createQuery("select u from User u").list();
}
Run Code Online (Sandbox Code Playgroud)

我的use.hbm.xml

<hibernate-mapping>

    <class name="demidov.pkg.domain.User" table="USER_DESC">

        <!-- Primary key ID will be generated depends on database configuration -->
        <id name="userId" column="ID">
            <generator class="native"></generator>
        </id>

        <property name="userName" column="USER_NAME" unique="true" />

        <property name="userPassword" column="USER_PASS" />

        <property name="userPriveleges" column="USER_PRIVLG" />

        <property name="userEmale" column="USER_EMALE" unique="true"/>

        <property name="userGender" column="USER_GENDER" />


        <!-- User is owner of relationships, all changes on user will effect UserMessage entity -->
        <set name="userMessageList" inverse="true" lazy="false" fetch="select">

            <key>
                <column …
Run Code Online (Sandbox Code Playgroud)

java hibernate nhibernate-mapping

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

Spring 中的异步事件需要大量时间来执行(轮到它了)

我有一个应用程序,每当对端点进行 REST 调用时,我都需要在其中触发电子邮件。设计是每当调用 REST 调用时,我将数据保存在数据库中,发出一个异步事件并返回。

我的问题是,由于大量请求不断涌现,发出的异步事件在很长一段时间内都没有机会。有时,当服务器启动数周时,延迟会不断增加。

场景

  1. 服务器端点被调用
  2. 服务器将数据保存到 db,发出一个 Spring 异步事件
  3. 从端点返回

由于有时调用侦听器很晚,因此调用 2 会延迟。

public class DataController {   
    @Inject
    ApplicationEventPublisher eventPublisher;

    @RequestMapping(value = "data", method = RequestMethod.POST)
    @ResponseStatus(HttpStatus.NO_CONTENT)
    public void addData(@RequestBody DataDTO data) {
        dataService.addData(data);
        eventPublisher.publishEvent(new DataRequest(new DataDTO());
    }
}



public class DataRequest extends ApplicationEvent {


    private DataDTO dataDTO;

    public DataRequest(DataDTO dataDTO) {
        super(dataDTO);
        this.dataDTO = dataDTO;
    }
}

@Component
public class DataListener {

    @EventListener
    @Async
    private void dataListener(DataDTO dataDTO) {
        // Send email
    }
}
Run Code Online (Sandbox Code Playgroud)

由于它是一个 Async …

java spring asynchronous spring-mvc

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

Spring&Hibernate:没有绑定到线程的会话

试图让Spring的事务管理工作,但它并没有像我希望的那样.

在请求需要我的数据库的任何内容时,我收到异常:

DEBUG: org.springframework.orm.hibernate3.SessionFactoryUtils - Opening Hibernate Session
DEBUG: org.springframework.orm.hibernate3.SessionFactoryUtils - Opening Hibernate Session
DEBUG: org.hibernate.impl.SessionImpl - opened session at timestamp: 12897642913
DEBUG: org.springframework.orm.hibernate3.SessionFactoryUtils - Closing Hibernate Session
DEBUG: org.springframework.orm.hibernate3.SessionFactoryUtils - Closing Hibernate Session
14-nov-2010 20:51:31 org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet mvc-dispatcher threw exception
org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
Run Code Online (Sandbox Code Playgroud)

我已经将我的属性移动到我的Spring上下文,看看是否有更好但没有.我的配置:

<?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:aop="http://www.springframework.org/schema/aop"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:oxm="http://www.springframework.org/schema/oxm"
    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
        http://www.springframework.org/schema/context …
Run Code Online (Sandbox Code Playgroud)

session spring hibernate transactions

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

配置无法从相对位置导入Bean定义

我的文件夹结构是:

src/main---java
           resources/META-INF/Spring-context/application.xml
           webapp/WEB-INF--web.xml
                           despatcher-servlet.xml
Run Code Online (Sandbox Code Playgroud)

webapp/WEB-INF/despatcher-servlet我试图导入application.xml之类的

<import resource="classes/META-INF/spring-context/application.xml"/>
Run Code Online (Sandbox Code Playgroud)

像配置问题一样出现异常:无法从相对位置导入bean定义[classes/META-INF/springcontext/application.xml] 任何人都可以帮助我.

spring

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

使用Spring Security进行双因素身份验证,例如Gmail

在这里,我的方案有点类似于Gmail的双因素身份验证.当用户成功登录(SMS代码发送给用户)时,他将被另一页面挑战以输入SMS代码.如果用户正确获取SMS代码,则会显示安全页面(如Gmail收件箱).

我对此做了一些研究,建议不是在登录时给ROLE_USER,给他PRE_AUTH_USER并显示他输入SMS代码的第二页; 成功后给他们ROLE_USER.

但是,我的问题是Spring有InsufficientAuthenticationException,在这种情况下我们不会使用它.在我的场景中是否还有其他更好的方法来实现双因素身份验证?

PS我有一些定制的弹簧安全配置.在我的登录页面,除了用户名和密码,我也有Recaptcha验证,我的authenticationProviderm authenticationSuccessHandler,logoutSuccessHandler,accessDeniedHandler都是自定义的.

spring spring-security

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

Spring MVC 中 JPA 中的自定义查询

我在 JPA 中使用自定义查询,它不允许我使用interval关键字。如果我不在- interval '7 days'查询中使用,它会提供正确的输出。

异常说: Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: interval near line 1, column 214

       @Query("select d from DomainName d , DomainNameReminder dr, Reseller  r"+
        " where d.reminder.id = dr.id  "+
        " and dr.secondNotification=current_date - interval '7 days' "+
        " and r.checkParty=true "+
        " and r.id = d.invoicingParty.id ")
        public List<Object> findDomainsBySecondNotificationDate();
Run Code Online (Sandbox Code Playgroud)

此查询基本上带来了今天之前 7 天具有第二个通知日期的所有记录。

我的接口被声明为

public interface DomainNameRepository extends JpaRepository<DomainName, Long>, 
QueryDslPredicateExecutor<DomainName> {
Run Code Online (Sandbox Code Playgroud)

我的查询在 中给出了正确的输出pgadmin postgresql client,我很惊讶为什么我不能在这里使用关键字。

java postgresql spring jpa spring-mvc

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

Spring Security 创建一个名为 USERS 的表

启动我的应用程序时,Spring Security 在我的 h2 数据库中创建两个表“用户”和“权限”。我的问题是,当我第二次启动应用程序时,数据库已经填充了这两个表,但是 Spring Security 直到想要创建它们。如果表不存在,我如何告诉 Spring Secutiry 仅创建表?或者我应该改变其他东西来解决这个问题?

Spring Secutiry 正在创建我从博客中获得的两个表,这些表描述了我查看过的一些代码。它说:“关于数据模型的一些说明。用户表中没有存储真实的用户名和密码。该表是由 Spring Security 定义的,用于通用用途,而不是特定于社交登录用例。”

博客链接

我得到的错误消息,一些 java 堆栈跟踪,是:

Caused by: org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement at line 1 of resource class path resource [org/springframework/security/core/userdetails/jdbc/users.ddl]: 
create table users(username varchar_ignorecase(50) not null primary key,password varchar_ignorecase(500) not null,enabled boolean not null); nested exception is org.h2.jdbc.JdbcSQLException: Table "USERS" already exists; 
SQL statement: create table users(username varchar_ignorecase(50) not null primary key,password varchar_ignorecase(500) not null,enabled boolean not null) [42101-175]
Run Code Online (Sandbox Code Playgroud)

Caused …
Run Code Online (Sandbox Code Playgroud)

spring h2 spring-security

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

无法解析符号Mock或InjectMocks

我正在使用Intellij,我的外部依赖项文件夹显示我正在使用mockito-all-1.10.19.jar.

我正在使用这个简单的Mockito示例.

import static org.mockito.Mockito.*;

@RunWith(MockitoJUnitRunner.class)
public class AuditUnitTests {

    @Mock
    AuditTwo two;

    @InjectMocks
    AuditOne one;

    @Test
    public void test1() {
        one.sayHelloFilter("Saurav");
        one.sayHelloFilter("Dravid");
        one.sayHelloFilter("Sachin");
        verify(two, times(2)).sayHello();
    }
}
Run Code Online (Sandbox Code Playgroud)

但是我的Intellij抱怨它无法解析Mock和InjectMocks注释.我该如何解决?

注意:我使用Ivy进行依赖管理:

   <dependency org="junit" name="junit" rev="4.12" conf="test"/>
    <dependency org="org.mockito" name="mockito-all" rev="1.10.19" conf="test"/>
Run Code Online (Sandbox Code Playgroud)

java intellij-idea mockito

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