- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用 Spring 的时间很短,但对于 wicket 来说我是新手。但我想尝试一下这个框架。
我想同时配置这两个框架。但我想避免使用 xml 配置文件。
我知道 Wicket 口可以这样配置,根据:
http://wicket.apache.org/guide/guide/single.html#helloWorld_2还有这个:
https://github.com/bitstorm/Wicket-tutorial-examples/tree/master/SpringInjectionExample
但现在我只收到错误:
lis 15, 2014 4:31:15 PM org.apache.catalina.core.StandardContext filterStart
SEVERE: Exception starting filter com.derp.wicket.ProjectFilter
java.lang.NoSuchMethodError: org.apache.wicket.protocol.http.WebApplication.setMetaData(Lorg/apache/wicket/MetaDataKey;Ljava/lang/Object;)Lorg/apache/wicket/Application;
at org.apache.wicket.spring.injection.annot.SpringComponentInjector.<init>(SpringComponentInjector.java:115)
at org.apache.wicket.spring.injection.annot.SpringComponentInjector.<init>(SpringComponentInjector.java:92)
at com.derp.wicket.WicketApplication.init(WicketApplication.java:52)
at org.apache.wicket.Application.initApplication(Application.java:823)
at org.apache.wicket.protocol.http.WicketFilter.init(WicketFilter.java:424)
at org.apache.wicket.protocol.http.WicketFilter.init(WicketFilter.java:351)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4603)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5210)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:724)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:700)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:581)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1686)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
lis 15, 2014 4:31:15 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error filterStart
lis 15, 2014 4:31:15 PM org.apache.catalina.core.StandardContext startInternal
这是我的配置:
package com.derp.common.init;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration.Dynamic;
import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.filter.HiddenHttpMethodFilter;
import org.springframework.web.servlet.DispatcherServlet;
public class Initializer implements WebApplicationInitializer {
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
ctx.register(WebAppConfig.class);
servletContext.addListener(new ContextLoaderListener(ctx));
ctx.setServletContext(servletContext);
Dynamic servlet = servletContext.addServlet("dispatcher", new DispatcherServlet(ctx));
servlet.addMapping("/");
servlet.setLoadOnStartup(1);
// Allow to use Put and Delete method for REST architecture
registerHiddenFieldFilter(servletContext);
}
private void registerHiddenFieldFilter(ServletContext aContext) {
aContext.addFilter("hiddenHttpMethodFilter", new HiddenHttpMethodFilter()).addMappingForUrlPatterns(null ,true, "/*");
}
}
package com.derp.common.init;
import java.util.Properties;
import javax.annotation.Resource;
import javax.sql.DataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.orm.hibernate4.HibernateTransactionManager;
import org.springframework.orm.hibernate4.LocalSessionFactoryBean;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.view.JstlView;
import org.springframework.web.servlet.view.UrlBasedViewResolver;
@Configuration
@ComponentScan("com.derp")
@EnableWebMvc
@EnableTransactionManagement
@PropertySource("classpath:application.properties")
public class WebAppConfig {
private static final String PROPERTY_NAME_DATABASE_DRIVER = "db.driver";
private static final String PROPERTY_NAME_DATABASE_PASSWORD = "db.password";
private static final String PROPERTY_NAME_DATABASE_URL = "db.url";
private static final String PROPERTY_NAME_DATABASE_USERNAME = "db.username";
private static final String PROPERTY_NAME_HIBERNATE_DIALECT = "hibernate.dialect";
private static final String PROPERTY_NAME_HIBERNATE_SHOW_SQL = "hibernate.show_sql";
private static final String PROPERTY_NAME_HIBERNATE_HBM2DDL_AUTO = "hibernate.hbm2ddl.auto";
private static final String PROPERTY_NAME_ENTITYMANAGER_PACKAGES_TO_SCAN_SERVICES = "services.entitymanager.packages.to.scan";
private static final String PROPERTY_NAME_ENTITYMANAGER_PACKAGES_TO_SCAN_COMMON = "common.entitymanager.packages.to.scan";
private static final String PROPERTY_NAME_ENTITYMANAGER_PACKAGES_TO_SCAN_CMS = "cms.entitymanager.packages.to.scan";
@Resource
private Environment env;
@Bean
public DataSource dataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName(env.getRequiredProperty(PROPERTY_NAME_DATABASE_DRIVER));
dataSource.setUrl(env.getRequiredProperty(PROPERTY_NAME_DATABASE_URL));
dataSource.setUsername(env.getRequiredProperty(PROPERTY_NAME_DATABASE_USERNAME));
dataSource.setPassword(env.getRequiredProperty(PROPERTY_NAME_DATABASE_PASSWORD));
return dataSource;
}
@Bean
public LocalSessionFactoryBean sessionFactory() {
LocalSessionFactoryBean sessionFactoryBean = new LocalSessionFactoryBean();
sessionFactoryBean.setDataSource(dataSource());
//sessionFactoryBean.setPackagesToScan(env.getRequiredProperty(PROPERTY_NAME_ENTITYMANAGER_PACKAGES_TO_SCAN));
sessionFactoryBean.setPackagesToScan(new String[] {
env.getRequiredProperty(PROPERTY_NAME_ENTITYMANAGER_PACKAGES_TO_SCAN_SERVICES),
env.getRequiredProperty(PROPERTY_NAME_ENTITYMANAGER_PACKAGES_TO_SCAN_COMMON),
env.getRequiredProperty(PROPERTY_NAME_ENTITYMANAGER_PACKAGES_TO_SCAN_CMS)
});
sessionFactoryBean.setHibernateProperties(hibProperties());
return sessionFactoryBean;
}
private Properties hibProperties() {
Properties properties = new Properties();
properties.put(PROPERTY_NAME_HIBERNATE_DIALECT, env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_DIALECT));
properties.put(PROPERTY_NAME_HIBERNATE_SHOW_SQL, env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_SHOW_SQL));
properties.put(PROPERTY_NAME_HIBERNATE_HBM2DDL_AUTO, env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_HBM2DDL_AUTO));
return properties;
}
@Bean
public HibernateTransactionManager transactionManager() {
HibernateTransactionManager transactionManager = new HibernateTransactionManager();
transactionManager.setSessionFactory(sessionFactory().getObject());
return transactionManager;
}
@Bean
public UrlBasedViewResolver setupViewResolver() {
UrlBasedViewResolver resolver = new UrlBasedViewResolver();
resolver.setPrefix("/WEB-INF/pages/");
resolver.setSuffix(".jsp");
resolver.setViewClass(JstlView.class);
return resolver;
}
}
package com.derp.wicket;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.spring.injection.annot.SpringBean;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.WebPage;
import com.derp.wicket.ejbBean.EnterpriseMessage;
public class HomePage extends WebPage {
private static final long serialVersionUID = 1L;
@SpringBean
private EnterpriseMessage enterpriseMessage;
public HomePage(final PageParameters parameters) {
super(parameters);
add(new Label("message", enterpriseMessage.message));
}
}
package com.derp.wicket;
import javax.servlet.annotation.WebInitParam;
import javax.servlet.annotation.WebFilter;
import org.apache.wicket.protocol.http.WicketFilter;
@WebFilter(value = "/*", initParams = { @WebInitParam(name = "applicationClassName", value = "com.derp.wicket.WicketApplication"),
@WebInitParam(name="filterMappingUrlPattern", value="/*")
})
public class ProjectFilter extends WicketFilter {
}
package com.derp.wicket;
import org.apache.wicket.protocol.http.WebApplication;
import org.apache.wicket.spring.injection.annot.SpringComponentInjector;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
/**
* Application object for your web application. If you want to run this application without deploying, run the Start class.
*
* @see org.wicketTutorial.Start#main(String[])
*/
public class WicketApplication extends WebApplication {
/**
* @see org.apache.wicket.Application#getHomePage()
*/
@Override
public Class<HomePage> getHomePage() {
return HomePage.class;
}
/**
* @see org.apache.wicket.Application#init()
*/
@Override
public void init() {
super.init();
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
ctx.scan("com.derp.wicket.ejbBean");
ctx.refresh();
getComponentInstantiationListeners().add(new SpringComponentInjector(this, ctx));
}
}
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<h2> <wicket:container wicket:id="message"></wicket:container></h2>
wwiicckkeet
</body>
</html>
任何人都可以帮助我解决这个问题吗?
最佳答案
看来您正在将 Wicket 与 Spring Web MVC 混合在一起。下面我粘贴了一些代码,或者您可以尝试在 github 上找到的代码:Spring Boot + Wicket:https://github.com/Pentadrago/spring-boot-example-wicket
我的WebApplicationInitializer
看起来像这样:
public class WebAppInitializer implements WebApplicationInitializer {
@Override
public void onStartup(ServletContext container) throws ServletException {
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
container.addListener(new ContextLoaderListener(context));
context.register(ApplicationConfiguration.class);
FilterRegistration filter = container.addFilter("wicket.myproject", WicketFilter.class);
filter.setInitParameter("applicationClassName", WicketApplication.class.getName());
filter.setInitParameter(WicketFilter.FILTER_MAPPING_PARAM, "/*");
filter.addMappingForUrlPatterns(null, false, "/*");
}
}
其中使用的 ApplicationConfiguration
类如下所示:
@Configuration
@ComponentScan
public class ApplicationConfiguration {
@Bean
public TestService testService(){
return new TestServiceImpl();
}
}
我继承的 WebApplication
类如下所示:
public class WicketApplication extends WebApplication {
@Override
public Class<? extends WebPage> getHomePage() {
return HomePage.class;
}
@Override
public void init() {
super.init();
getComponentInstantiationListeners().add(new SpringComponentInjector(this));
}
}
在你的 POM 中你应该有这个 deps:
<dependency>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket-core</artifactId>
<version>6.17.0</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket-spring</artifactId>
<version>6.17.0</version>
</dependency>
关于java - 使用 Java Conf 而不是 xml 配置 Spring Wicket,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26947732/
我在play官方网站上关注了“Learn”。我使用的是window 7+Chrome。 D:\tester\play>dir Volume in drive D is APPLIS Volum
我有一个 play 1.2.5 应用程序,想将它部署到某个地方(这样我就可以为一些 OAuth 回调注册它)。我正在尝试将其推送到 heroku,但出现以下错误 -----> Play! app de
周围有两个配置文件,/etc/nginx/conf.d/default.conf和 /etc/nginx/nginx.conf,但是启用了哪一个呢?我运行的是 CentOS6.4 和 nginx/1.
我已经在Flume 1.6.0-cdh5.4.2(CentOS)中安装了cloudera VM 我认为配置和一切都很好 我运行了以下命令槽 flume-ng --conf /conf agent -
为了避免对我本地托管的 apache-tomcat Web 服务器上托管的 Web 应用程序进行点击劫持攻击,我正在尝试编辑“httpd.conf”文件以向其附加 X 选项。 用“sudo nano/
当我想为 intel Galileo 构建一个 yocto 镜像时,我按照网站中提到的这些说明进行操作 https://software.intel.com/en-us/blogs/2015/03/0
如果我有一个名为 mysite.conf 的文件存储在 /etc/nginx/conf.d .有没有办法获取字符串值'mysite'从conf文件中? 我想多次符号链接(symbolic link)一
为大学生编写一个应用程序——显示一个系列表,你点击一个,然后它会显示该系的类(class),点击一个,然后显示教授该类(class)的教授。 URL conf 有问题——我的应用程序不断将我重定向到错
当试图启动 apache 时 sudo /etc/init.d/apache2 restart 我得到了错误 apache2: Syntax error on line 260 of /etc/apa
我关注 this tutorial我找不到本教程第二步的 phpmyadmin.conf。我在/etc/apache2/conf-available/中只有以下文件 charset.conf othe
httpd.conf(/etc/httpd/conf/httpd.conf) 和 ssl.conf(/etc/httpd/conf.d/ssl.conf) 有什么区别 文件? 我正在尝试在我的站点上设
所有配置都被包含在内,并且 conf 测试也通过了。但是 Nginx 仍然提供来自 /usr/share/nginx/html 的默认 HTML。 , 而不是 conf.d 目录中 conf 文件的位
我是 psql 的新手,我遇到了一些我认为是错误放置的 .conf 文件引起的问题。当我尝试登录我之前创建的数据库时出现错误 $ psql corporation psql: could not co
我在 /etc/httpd/conf.d/vhost.conf 中的虚拟主机配置如下所示: NameVirtualHost * ServerName www.example.com
我遵循了教程:http://www.webopius.com/content/355/getting-mamp-working-with-ssl-on-os-x获取 ssl 证书。但是,我无法在 st
是否有一个 spark 属性,我们可以在执行 spark 提交时设置它指定 hadoop 配置路径,专门指向自定义 hdfs-site.xml 和 core-site.xml 文件 最佳答案 首选的方
在NameNode和JobTracker不是同一台服务器的hadoop集群(1.x版本)中,conf/masters和conf/slaves是需要在NameNode和JobTracker上同时指定还是
我从 Here 下载 Redis-x64-3.2.100.zip ,当我提取它时,我看到两个文件 redis.windows.conf 和 redis.windows-service.conf,我比较
我目前正在检查我们的 JBoss AS7.1 服务器配置,我在我们的 jboss/standalone/bin 目录中发现了这两个以前配置的文件: standalone.conf standalone
我一直在使用这个教程http://mpjexpress.blogspot.co.nz/2010/05/executing-and-debugging-mpj-express.html 、文本:步骤 1
我是一名优秀的程序员,十分优秀!