我有Spring WebMVC应用程序使用@PreAuthorize
和@PostAuthorice
注释控制器方法.但是这些注释被忽略了,因为我没有在我的Spring安全性中启用它.
如果我有一个,spring-security.xml
我可以使用以下行启用它:
<global-method-security pre-post-annotations="enabled" />
Run Code Online (Sandbox Code Playgroud)
不幸的是,我有一个完整的基于注释的配置.Spring-Security原则上适用于我的应用程序.
我的问题:如何使用基于注释的MVC配置启用前后注释?
这是我的WebSecurityConfigurerAdapter
实施:
@Configuration
@EnableWebMvcSecurity()
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired DataSource dataSource;
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.jdbcAuthentication()
.dataSource(dataSource)
.passwordEncoder(new ShaPasswordEncoder(256))
.usersByUsernameQuery("select username,password, enabled from user where USERNAME=?")
.authoritiesByUsernameQuery("select u.username, r.name from user u, role r, user_has_role uhr where u.id = uhr.user_id and r.id = uhr.role_id and u.username = ? ");
}
@Override
protected void configure(HttpSecurity http) throws …
Run Code Online (Sandbox Code Playgroud) 在我的示例中@DateTimeFormat
,嵌套对象时忽略注释:
class Person {
private Date birthdate;
// other fields
@DateTimeFormat(pattern="dd.MM.yyyy")
public Date getBirthdate(){
return birthdate;
}
// Other getters/setters
}
Run Code Online (Sandbox Code Playgroud)
我有一个嵌套这个对象的类.
class PersonGroup {
private Person person1;
private Person person2;
// other fields
@Valid
public Person getPerson1(){
return person1;
}
// also tried without @Valid-Annotation
public Person getPerson2(){
return person2;
}
// Other getters/setters
}
Run Code Online (Sandbox Code Playgroud)
我PersonGroup
在一个@Controler
-Method中添加了一个类型的对象给我的模型,如下所示:
model.addAttribute("myGroup", filledPersonGroup);
Run Code Online (Sandbox Code Playgroud)
在JSP中,我使用打印嵌套变量:
<form:form modelAttribute="myGroup" action="..." >
<form:input path="person1.birthdate" >
<form:input path="person2.birthdate" >
...
</form:form >
Run Code Online (Sandbox Code Playgroud)
但不幸的是,输入字段中的日期值格式不正确(但原则上显示日期).当我直接将类的实例添加 …
我正在使用Hibernate版本4.3.5.Final.这里的问题是Hibernate找到Foo
属性address
的情况具有不同情况的实体(例如"BLAFOO").但是,在我的例子中,ex.ignoreCase()
没有被调用.
我只想找到符合确切情况的实体.我究竟做错了什么?
Foo myBean = new Foo();
myBean.setAddress("blaFoo");
Example ex = Example.create(myBean);
ex.excludeZeroes();
//ex.ignoreCase();
DetachedCriteria crit = DetachedCriteria.forClass(Foo.class).add(ex);
List<MonitoredApp> apps = dao.findByDetachedCriteria(crit);
Run Code Online (Sandbox Code Playgroud) 我如何强制mvn发布:执行部署到我的发布而不是我的快照存储库?release:perform总是部署SNAPSHOT版本.这没有任何意义恕我直言
我有我的pom.xml
<groupId>com.mydomain</groupId>
<artifactId>MyArtifactName</artifactId>
<version>1.0.6-SNAPSHOT</version>
<packaging>jar</packaging>
<name>MyArtifactName</name>
<url>http://maven.apache.org</url>
<distributionManagement>
<repository>
<id>central</id>
<url>http://repo.example.com/artifactory/libs-release-local</url>
<name>libs-release-local</name>
</repository>
<snapshotRepository>
<id>central</id>
<url>http://repo.example.com/artifactory/libs-snapshot-local</url>
<name>libs-snapshot-local</name>
</snapshotRepository>
</distributionManagement>
<scm>
<tag>HEAD</tag>
<url>http://git.example.com/someUser/myproject</url>
<connection>scm:git:git@git.example.com/someUser/myproject.git</connection>
<developerConnection>scm:git:git@git.example.com/someUser/myproject.git</developerConnection>
</scm>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.4.2</version>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)