小编Ali*_*ani的帖子

SQL:删除所有可用表中的所有数据

我使用oracle DB来维护30多个表,如何删除所有表中的所有数据?我只想删除数据但不删除表.

sql oracle

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

为Spring TestRestTemplate集成测试添加标头值

我正在使用TestRestTemplate我们产品的集成测试.

我有一个看起来像这样的测试:

@Test
public void testDeviceQuery() {
    ResponseEntity<Page> deviceInfoPage = template.getForEntity(base, Page.class);

    // validation code here
}
Run Code Online (Sandbox Code Playgroud)

此特定请求需要Header值.有人可以告诉我如何在TestRestTemplate电话中添加标题吗?

java spring integration-testing spring-boot

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

我们可以有条件地申报春豆吗?

有没有办法我们可以有条件地声明一个Spring bean:

<bean class="path.to.the.class.MyClass" if="${1+2=3}" />
Run Code Online (Sandbox Code Playgroud)

它将是有用的,而不必使用配置文件.我没有考虑具体的用例,但它来到我身边.

java spring

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

允许所有URL,但Spring安全性中只有一个

我想保护一个URL,同时允许匿名访问其他所有内容.

我在互联网上看到的Java配置示例似乎都表明您需要明确地显示permitAll每个URL,并且适用hasRole于需要保护的URL.在我的情况下,这会创建一个非常笨拙的java代码,我每次向应用程序添加新URL时都会对其进行修改.我可以使用更简单的java配置吗?

并且还要注意,在我的情况下,我正在保护的URL是一个子资源,比如说employee/me,我希望employee/list等等,可以匿名访问.

java spring spring-security

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

Spring缓存登录@Cacheable命中

目前我正在使用Spring Cache和@Cacheable/ @CacheEvictannotations.

我想得到某种类似的控制台日志声明 "INFO: i got those values from the cache, NOT from the host. awesome"

有一个干净,简单的方法吗?slf4j如果有任何兴趣,我们显然使用btw.

java spring slf4j spring-cache

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

Spring中不同语境的目的和关系

我正在使用春季启动项目.我想了解不同背景的目的和关系?

例如,Spring Security上下文,Spring Context,Servlet Context等(还有更多的上下文吗?)

java spring spring-security

18
推荐指数
2
解决办法
1901
查看次数

请求映射的默认请求方法类型是什么?

什么是默认的请求方法类型@RequestMapping

@RequestMapping(value = "addGoal")
public String addGoal(Model model) {...}
Run Code Online (Sandbox Code Playgroud)

java spring spring-mvc

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

在Intellij Idea 15中没有"从模板创建"Spring MVC?

在IntelliJ Idea 14中,我可以使用以下内容:

文件>新建项目> Spring>从模板创建项目> Spring MVC

使用Maven创建Spring MVC应用程序模板.现在这个功能在其他地方吗?

问题是,如果我不使用模板,则没有webapp制作文件夹.我在创建项目时检查Spring + Spring MVC + Web应用程序,但没有webapp文件夹.

有任何想法吗?

spring spring-mvc intellij-idea

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

如何在Spring'HandlerMethodArgumentResolver'中多次读取请求体?

我正在尝试解决某些RequestMapping方法的某些参数,从请求体中提取值并验证它们并将它们注入到某些带注释的参数中.

@Override
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
                              NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
    // 1, get corresponding input parameter from NativeWebRequest
    // 2, validate
    // 3, type convertion and assemble value to return
    return null;
}
Run Code Online (Sandbox Code Playgroud)

最大的问题是我发现HttpServletRequest(get from NativeWebRequest)无法读取输入流(某些参数在请求体中)不止一次.那么我怎样才能多次检索Inputstream/ Reader或请求体?

java spring spring-mvc

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

Spring Boot Security - java.lang.IllegalArgumentException:无法传递null GrantedAuthority集合

我是Spring boot和Spring Security的新手.我目前的Spring启动版本1.3.7.RELEASE有什么问题吗?我该如何解决这个问题?

SecurityConfig.java看起来如下:

@Configuration
@EnableGlobalMethodSecurity(securedEnabled = true)
public class SecurityConfig extends WebSecurityConfigurerAdapter {
    @Autowired
    public void configureAuth(AuthenticationManagerBuilder auth) throws Exception {
        auth
            .inMemoryAuthentication()
                .withUser("thomas")
                .password("password")
            .and()
                .withUser("joe")
                .password("password")
                .roles("USER");
    }
}
Run Code Online (Sandbox Code Playgroud)

这是我的pom.xml档案:

<?xml version="1.0" encoding="UTF-8"?>
<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>springsecuritydemo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>springsecuritydemo</name>
<description>springsecuritydemo</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.3.7.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId> …
Run Code Online (Sandbox Code Playgroud)

java spring spring-security spring-boot

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