我想为许多项目重用某些过滤器,所以我想提取它并使用一个jar将其添加到任何Web App.
对于构建我正在使用Gradle 1.3和以下build.gradle文件:
apply plugin: 'java'
dependencies {
compile group:'org.slf4j', name:'slf4j-api', version:'1.7.+'
testCompile group:'junit', name:'junit', version:'4.+'
compile group:'org.springframework', name:'spring-web', version:'3.+'
compile group:'org.slf4j', name:'slf4j-log4j12', version:'1.6.+'
compile group:'log4j', name:'log4j', version:'1.2.+'
providedCompile group: 'javax.servlet', name: 'javax.servlet-api', version:'3.+'
}
repositories {
mavenCentral()
}
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,我需要servlet api成功编译此过滤器,因此我想将其添加为maven提供的依赖项.
无论如何,运行后gradle build我得到以下错误:
无法在根项目'hibernate-conversation-context'上找到方法providedCompile()的参数[{group = javax.servlet,name = javax.servlet-api,version = 3. +}].
现在,我知道在没有WAR插件的情况下我不能使用providedCompile,但我需要将项目作为一个简单的JAR.还有另一种方法吗?
我发现这个问题是从java String中获取java.util.streams.IntStream但是我现在还没有找到这个方法,因为我使用的是Java 8.
更正:正如你们所指出的那样,我使用的是Java 7.现在方法chars()就在那里.但问题仍然适用:
如何Stream<Character>从字符串中获取?
在Spring JavaConfig中,我可以定义属性源并注入到Environment中
@PropertySource("classpath:application.properties")
@Inject private Environment environment;
Run Code Online (Sandbox Code Playgroud)
如果在xml中我该怎么做?我使用context:property-placeholder,并在JavaConfig类@ImportResource上导入xml.但我无法使用environment.getProperty("xx")检索属性文件中定义的属性
<context:property-placeholder location="classpath:application.properties" />
Run Code Online (Sandbox Code Playgroud) 我需要取消Spring定时器执行或至少根据某些条件更改执行频率.正在使用org.springframework.scheduling.quartz.SimpleTriggerBean和org.springframework.scheduling.timer.ScheduledTimerTask.找不到怎么做的方法.
不久前,我正在使用HTML5 的w3c 验证器,并尝试用一个标签来替换已弃用的<tt>标签。我输入了这个小例子:
<!DOCTYPE html>
<html>
<head><title>Valid tags inside other tags</title></head>
<body>
<p>Inside paragraph you cannot use <pre>preformated text</pre></p>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
并得到这个错误:
第 6 行,第 66 列:范围内没有 p 元素,但看到 ap 结束标记。
但是当我更改标签<pre>的标签时<code>,没有引发错误。
我想这是因为你不能在段落中包含预先格式化的文本,但我没有运气搜索正则表达式或可以将我指向其他标签内的有效标签的东西。
任何人都可以指出我这样的资源吗?
编辑:
事实证明,我不擅长阅读文档,而且还没有看过块级元素。所以,现在的问题是,我如何知道哪些是有效的内联元素以及如何在其他块级元素内使用块级元素?
我正在阅读Collections.shuffle(List)javadoc,然后看看RandomAccess javadoc:
List实现使用的标记接口,表示它们支持快速(通常是恒定时间)随机访问.[...]
我想知道为什么这个接口(如Serializable)没有方法?这个的设计原因是什么?
即使只列出"实现"此接口,为什么不将E设置get()为方法呢?我知道并非每个列表都是随机访问,但如果没有方法,我该如何使用这个界面呢?
像这样的东西:
if(object instanceof RandomAccess){
// should I cast it if no operations can be done? why?
}
Run Code Online (Sandbox Code Playgroud)
此外,只有列表可以是RandomAccess?文件怎么样?
我正在阅读Thymeleaf + Spring 3 Tutorial并尝试构建模块化应用程序.我的目标是能够从类路径中的Jars加载百万富翁模板.
为此我SpringTemplateEngine在下一个xml中配置了一个:
<bean id="templateEngine" class="org.thymeleaf.spring3.SpringTemplateEngine">
<property name="templateResolvers">
<util:set>
<ref bean="servletContextTemplateResolver" />
<ref bean="classpathPluginTemplateResolver" />
</util:set>
</property>
</bean>
<bean id="classpathPluginTemplateResolver"
class="org.mael.codex.arcana.web.thymeleaf.templates.ClasspathPluginTemplateResolver">
<property name="prefix" value="/META-INF/codexarcana/plugin/views" />
<property name="suffix" value=".html" />
<property name="templateMode" value="HTML5" />
</bean>
Run Code Online (Sandbox Code Playgroud)
和ClasspathPluginTemplateResolver代码:
public class ClasspathPluginTemplateResolver extends TemplateResolver {
public ClasspathPluginTemplateResolver() {
super();
super.setResourceResolver(new ClasspathTemplateResolver());
}
@Override
public void setResourceResolver(IResourceResolver resourceResolver) {
throw new ConfigurationException("Cannot set a resource resolver on "
+ this.getClass().getName() + ". If "
+ "you want to …Run Code Online (Sandbox Code Playgroud) java ×6
spring ×3
collections ×1
exception ×1
gradle ×1
html ×1
java-8 ×1
java-stream ×1
properties ×1
scheduling ×1
spring-mvc ×1
thymeleaf ×1
validation ×1