springside / springside4 Goto Github PK
View Code? Open in Web Editor NEWA Spring Framework based, pragmatic style JavaEE application reference architecture.
Home Page: http://www.springside.io
License: Apache License 2.0
A Spring Framework based, pragmatic style JavaEE application reference architecture.
Home Page: http://www.springside.io
License: Apache License 2.0
JOSN用的包:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
</dependency>
实体可以正确的转化为JSON格式.
控制器里面使用@responsebody,但是返回前台页面显示出来的却是中文乱码。
场景:QuartzJob里面调用ArtilceManager,ArtilceManager里面用到了Hibernate Validator。
运行时,提示ArticleDao注入类型不正确
在最后发布前,以quickstart为模板制作archetype.
今天结合Spring Data JPA把你的IdEntity改进了一下:
public abstract class IdEntity implements Serializable {
protected Long id;
@Temporal(TemporalType.TIMESTAMP)
private Date createdDate;
@Temporal(TemporalType.TIMESTAMP)
private Date lastModifiedDate;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@Type(type = "org.joda.time.contrib.hibernate.PersistentDateTime")
public DateTime getCreatedDate() {
return null == createdDate ? null : new DateTime(createdDate);
}
public void setCreatedDate(final DateTime createdDate) {
this.createdDate = null == createdDate ? null : createdDate.toDate();
}
@Type(type = "org.joda.time.contrib.hibernate.PersistentDateTime")
public DateTime getLastModifiedDate() {
return null == lastModifiedDate ? null : new DateTime(lastModifiedDate);
}
public void setLastModifiedDate(final DateTime lastModifiedDate) {
this.lastModifiedDate = null == lastModifiedDate ? null : lastModifiedDate.toDate();
}
结果报错(已添加joda-time-hibernate 1.3的依赖):
2012-04-05 22:53:02.587:WARN:oejs.ServletHandler:/CMS/article/list/3
java.lang.AbstractMethodError: org.joda.time.contrib.hibernate.PersistentDateTime.nullSafeGet(Ljava/sql/ResultSet;[Ljava/lang/String;Lorg/hibernate/engine/spi/SessionImplementor;Ljava/lang/Object;)Ljava/lang/Object;
Joda之于Hibernate4是不可以的:
Please note that version 1.3 is for Hibernate 3.6 and not Hibernate 4.0 (as the Hibernate team have made another incompatible change). The usertype project handles Hibernate 4.0. It is also more up to date and more complete than this project in general.
http://joda-time.sourceforge.net/contrib/hibernate/index.html
推荐使用Usertype
http://usertype.sourceforge.net/
相应的修改为
@type(type="org.jadira.usertype.dateandtime.joda.PersistentDateTime")
Insert等语句同时支持H2与Oracle,不同的主键语法。
功能测试使用MySQL数据库,报错:No columns found for table '?' that are supported by dbunit
参考:http://forums.mysql.com/read.php?39,137564,137629#msg-137629
You're correct. For legacy reasons (including compatibility with ODBC, and SQL Server), JDBC's concept of "catalog" maps to MySQL's concept of "databases".
Starting in MySQL-4.1, "schema" is an alias for "database", but it doesn't act like a SQL-standard schema, so we don't support the concept in the JDBC driver.
对比PlayFramework2的 Example,降低springside的入门门槛。
将用例改为TodoList ,并加入Spring MVC做到Restful API, 成为最佳入门示例。
原有mini-web/mini-service中的的复杂内容将移回showcase中。
remainning tasks:
1.将CXF移回showcase
2.将Mybatis移回showcase
3.将Shiro的Resource base的控制移到showcase
4.将Shiro的Role base的控制移到quickstart
5.将JQuery-Validate的高级版校验移到showcase
另外Showcase中一些非常用的部分也进行删减,尽量保持最新的实践展示。
SiteMesh3-Alpha2还是会出现NO Content这种错误,回退吧。
If I submit a wrong issue, how can I delete it?
Or, only administrator can delete it, right?
一些零散又无逻辑,直接跳转JSP的路径, 直接在spring-mvc.xml中用如下方式定义,不需要定義Controller
<mvc:view-controller path="/" view-name="index"/>
<mvc:view-controller path="/web/mashup-client" view-name="/web/mashup-client"/>
走向实战,Quickstart应该演示生产环境用MySQL,开发环境用H2的实际场景。
就是把常用的 注解 省略了 例如 @RequestMapping
先不说性能 就开发 跟struts2有差距啊 一个controller类里面 满屏的 @@@@@@@@..............
remanining task: spring taglib的 checkbox输出格式不符合bootstrap的约定
@Autowired可简化写法地址,
将set方法去掉,然后把@Autowired移到变量申明处。
如下代码:https://github.com/springside/springside4/blob/master/examples/showcase/src/main/java/org/springside/examples/showcase/common/web/UserController.java
package org.springside.examples.showcase.common.web;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springside.examples.showcase.common.entity.User;
import org.springside.examples.showcase.common.service.AccountManager;
@controller
@RequestMapping(value = "/common/user")
public class UserController {
private AccountManager accountManager;
@RequestMapping(value = { "list", "" })
public String list(Model model) {
List<User> users = accountManager.getAllUser();
model.addAttribute("users", users);
return "common/userList";
}
@Autowired
public void setAccountManager(AccountManager accountManager) {
this.accountManager = accountManager;
}
}
可以改成这样会减少代码:
package org.springside.examples.showcase.common.web;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springside.examples.showcase.common.entity.User;
import org.springside.examples.showcase.common.service.AccountManager;
@controller
@RequestMapping(value = "/common/user")
public class UserController {
@Autowired
private AccountManager accountManager;
@RequestMapping(value = { "list", "" })
public String list(Model model) {
List<User> users = accountManager.getAllUser();
model.addAttribute("users", users);
return "common/userList";
}
}
临时解决办法,为删除这个mediaType 定义,至少保证了json能用。 完整的解决办法等环境搭好了再来试试
RT,通过GrizzlyWebServer的方式可以实现,但是如果用GrizzlyServerFactory.createHttpServer的话,不成功,不能返回内容。请问calvin有没有解决方案。
针对ehcache的几个配置参数做了下 测试 ,发现实际结果与官方文档说明不一致,希望白衣大侠能指点下原因
(环境 , ehcache 版本为 2.5.2 , 基于 springside的 EhcacheDemo 进行的测试)
通过测试发现 ,只要 overflowToDisk 设置为 true , ehcache 不管 maxEntriesLocalHeap 和 maxBytesLocalHeap的 阀值设置 多少,始终会 往硬盘中写入数据 ,这与 官方文档的描述 不一致. (官方文档地址: http://ehcache.org/documentation/configuration/cache-size)
希望白衣大侠能够 指点下 这个原因 ,是否为 ehcache 新版本的 bug
应用Spring Data JPA中的搜索与分页能力,并与页面相结合。
暂时不与JQ-Grid等Jquery控件集成。
改进Perf4j或使用其他的应用性能监控框架,或参考statsd自己写一个Counter并将数据发送到Graphited
更新ehcache配置文件到2.x的版本,而且重新加入RMI集群版的配置文件。
在showcase示例配置shiro-ehcache缓存。
H2使用改进,不再强制要求单独启动H2 TCP server,而是使用嵌入式,但可持久化的模式。
mini-web中只有一个AccountManager,这个manager能正确autowired到controller中。
但我自己写了一个MyManager,这个manager里面autowired其他dao,但这个manager无法autowired到controller中。
启动时错误:
Error creating bean with name 'userController': Injection of autowired dependencies failed;
经过测试发现有以下现象:
1、去掉MyManager上的@transactional(readOnly = true),可以正确autowired。
2、去掉MyManager中的所有方法,只留autowired的dao声明,可以正确autowired。
3、考虑到为什么AccountManager可以正确autowired到任何controller,发现AccountManager和applicationContext-shiro.xml里面的shiroDbRealm有关,但shiroDbRealm不是通过annotation的方式声明的,我把mymanager在shiroDbRealm中autowired一下,mymanager也可以正确autowired到其他controller中。
我自己解决不了,不知道哪里有问题?
看springside的所有例子,也就一个accountManager,因此可能这个问题白衣也没能发现,是ss4中的一个bug?
重现错误方法很简单:直接复制一份AccountManager,改个名字,任何在任何一个Controller中autowired就行,任何启动的时候就会报错。
mvn jetty:run 启动showcase, jetty启动后, 无法打开localhost:8080/showcase/,网页一直无响应, 直接kill jetty进程,发现OutOfMemory异常, DEBUG日志如下:
版本: 639fa32, 怀疑有死循环.
[INFO] Started Jetty Server
2012-04-19 22:12:26,217 [qtp1437285594-150] DEBUG ctory.support.DefaultListableBeanFactory -Returning cached instance of singleton bean 'entityManagerFactory'
2012-04-19 22:12:26,217 [qtp1437285594-150] DEBUG pa.support.OpenEntityManagerInViewFilter -Opening JPA EntityManager in OpenEntityManagerInViewFilter
2012-04-19 22:12:26,217 [qtp1437285594-150] DEBUG org.hibernate.internal.SessionImpl -Opened session at timestamp: 13348447462
2012-04-19 22:12:26,284 [qtp1437285594-150] DEBUG gframework.web.servlet.DispatcherServlet -DispatcherServlet with name 'springServlet' processing GET request for [/showcase/]
2012-04-19 22:12:26,287 [qtp1437285594-150] DEBUG .annotation.RequestMappingHandlerMapping -Looking up handler method for path /
2012-04-19 22:12:26,292 [qtp1437285594-150] DEBUG .annotation.RequestMappingHandlerMapping -Did not find handler method for [/]
2012-04-19 22:12:26,293 [qtp1437285594-150] DEBUG .servlet.handler.SimpleUrlHandlerMapping -Mapping [/] to HandlerExecutionChain with handler [org.springframework.web.servlet.mvc.ParameterizableViewController@54012da5] and 1 interceptor
2012-04-19 22:12:26,294 [qtp1437285594-150] DEBUG gframework.web.servlet.DispatcherServlet -Last-Modified value for [/showcase/] is: -1
2012-04-19 22:12:26,301 [qtp1437285594-150] DEBUG gframework.web.servlet.DispatcherServlet -Rendering view [org.springframework.web.servlet.view.InternalResourceView: unnamed; URL [/index]] in DispatcherServlet with name 'springServlet'
2012-04-19 22:12:26,302 [qtp1437285594-150] DEBUG rk.web.servlet.view.InternalResourceView -Forwarding to resource [/index] in InternalResourceView 'null'
2012-04-19 22:12:26,304 [qtp1437285594-150] DEBUG gframework.web.servlet.DispatcherServlet -DispatcherServlet with name 'springServlet' processing GET request for [/showcase/index]
2012-04-19 22:12:26,304 [qtp1437285594-150] DEBUG .annotation.RequestMappingHandlerMapping -Looking up handler method for path /index
2012-04-19 22:12:26,307 [qtp1437285594-150] DEBUG .annotation.RequestMappingHandlerMapping -Returning handler method [public java.lang.String org.springside.examples.showcase.common.web.GeneralController.index()]
2012-04-19 22:12:26,308 [qtp1437285594-150] DEBUG ctory.support.DefaultListableBeanFactory -Returning cached instance of singleton bean 'generalController'
2012-04-19 22:12:26,309 [qtp1437285594-150] DEBUG gframework.web.servlet.DispatcherServlet -Last-Modified value for [/showcase/index] is: -1
2012-04-19 22:12:26,324 [qtp1437285594-150] DEBUG ctory.support.DefaultListableBeanFactory -Invoking afterPropertiesSet() on bean with name 'index'
2012-04-19 22:12:26,324 [qtp1437285594-150] DEBUG gframework.web.servlet.DispatcherServlet -Rendering view [org.springframework.web.servlet.view.JstlView: name 'index'; URL [/WEB-INF/views/index.jsp]] in DispatcherServlet with name 'springServlet'
2012-04-19 22:12:26,336 [qtp1437285594-150] DEBUG pringframework.web.servlet.view.JstlView -Forwarding to resource [/WEB-INF/views/index.jsp] in InternalResourceView 'index'
2012-04-19 22:12:27,792 [qtp1437285594-150] DEBUG gframework.web.servlet.DispatcherServlet -Successfully completed request
2012-04-19 22:12:27,795 [qtp1437285594-150] DEBUG ctory.support.DefaultListableBeanFactory -Returning cached instance of singleton bean 'sqlSessionFactory'
2012-04-19 22:12:27,795 [qtp1437285594-150] DEBUG gframework.web.servlet.DispatcherServlet -Successfully completed request
2012-04-19 22:12:27,796 [qtp1437285594-150] DEBUG ctory.support.DefaultListableBeanFactory -Returning cached instance of singleton bean 'sqlSessionFactory'
2012-04-19 22:12:32,572 [qtp1437285594-150] DEBUG pa.support.OpenEntityManagerInViewFilter -Closing JPA EntityManager in OpenEntityManagerInViewFilter
2012-04-19 22:12:32,572 [qtp1437285594-150] DEBUG mework.orm.jpa.EntityManagerFactoryUtils -Closing JPA EntityManager
2012-04-19 22:12:36,781 [QuartzScheduler_clusterQuartzScheduler-pandazxx-air1334844736574_ClusterManager] DEBUG k.jdbc.datasource.SimpleDriverDataSource -Creating new JDBC Driver Connection to [jdbc:h2:file:/showcase-quartz4;AUTO_SERVER=TRUE]/showcase-quartz4;AUTO_SERVER=TRUE]
2012-04-19 22:12:47,370 [localQuartzScheduler_QuartzSchedulerThread] DEBUG org.quartz.core.QuartzSchedulerThread -batch acquisition of 0 triggers
2012-04-19 22:12:51,317 [clusterQuartzScheduler_QuartzSchedulerThread] DEBUG k.jdbc.datasource.SimpleDriverDataSource -Creating new JDBC Driver Connection to [jdbc:h2:file:
2012-04-19 22:13:17,233 [localQuartzScheduler_QuartzSchedulerThread] DEBUG org.quartz.core.QuartzSchedulerThread -batch acquisition of 0 triggers
2012-04-19 22:13:22,132 [QuartzScheduler_clusterQuartzScheduler-pandazxx-air1334844736574_MisfireHandler] DEBUG cheduling.quartz.LocalDataSourceJobStore -MisfireHandler: scanning for misfires...
2012-04-19 22:13:25,066 [QuartzScheduler_clusterQuartzScheduler-pandazxx-air1334844736574_MisfireHandler] DEBUG k.jdbc.datasource.SimpleDriverDataSource -Creating new JDBC Driver Connection to [jdbc:h2:file:~/showcase-quartz4;AUTO_SERVER=TRUE]
2012-04-19 22:13:54,889 [localQuartzScheduler_QuartzSchedulerThread] DEBUG org.quartz.core.QuartzSchedulerThread -batch acquisition of 0 triggers
2012-04-19 22:14:37,343 [localQuartzScheduler_QuartzSchedulerThread] DEBUG org.quartz.core.QuartzSchedulerThread -batch acquisition of 0 triggers
^C
Java HotSpot(TM) 64-Bit Server VM warning: Exception java.lang.OutOfMemoryError occurred dispatching signal Unknown Signal to handler- the VM may need to be forcibly terminated
AES支持IV(初始变量), SHA1支持Salt(盐值),让相同的原文能加密出不同密文,增加安全性。
最近发现Json的变边了
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
</dependency>
变成了:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
</dependency>
导致在控制器中注释@responsebody,返回Json数据时提示406错误。
TODO裡是FREEMARKER 改成 VELOCITY。現在是否改回來了。
Jquery Validate Plugin实现客户端Validate达到更好的客户体验。
Spring MVC的Hibernate Validator主要用于防止恶意用户提交并实现Jquery Validate不能完成的验证。
原来还想用Hamcrest ,最后放弃掉。
readme.txt中
Offical Site: http://www.springside.org.cn
需要验证
使用WebDriverWait与ExpectedConditions实现灵活等待。
取消对Selenium1.0的依赖,通过加大implicitlyWait解决waitForPageLoad的问题。
类名 org.springside.examples.miniservice.webservice.rs.server.UserResouceService
google 了下, 解决的方法是
将UserResouceService 第71行 List searchUser 修改为 UserDTO[] searchUser (已验证可行)
或者
将UserResouceService 第71行 List searchUser 修改为 ArrayList searchUser(未验证)
哪位tx checkin 自己的修改的时候, 能不能顺便改下? 没人check in 的话等我哪天配好环境自己搞下
7.UT的初始化數據只啟動一次。
8.Spring Profile配置升级,设定默认Profile为Production,functional test通过改变环境变量而不是使用另一个web.xml来改变profile。独立出functional test的Profile。Maven refresh db时会读取重载过的application.local的属性。
可能是爬虫,有没有好的解决方案?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.