velocity

Can I convert an artifactId to a classname prefix in my maven archetype?

自闭症网瘾萝莉.ら 提交于 2019-12-03 23:35:21
I'm creating a maven archetype and in the projects generated a want a class that is named after the artifact id of the generated project. The artifact id will be formatted like: the-project-name and the class should be named TheProjectNameMain . I've tried to do this in my archetype-metadata.xml but I can't get it right. <archetype-descriptor> <requiredProperties> <requiredProperty key="classNamePrefix"> <defaultValue>${WordUtils.capitalize(artifactId.replaceAll("-", " ")).replaceAll(" ", "")}</defaultValue> </requiredProperty> </requiredProperties> </archetype-descriptor> As you can see i

Jfinal使用Velocity视图部署到tomcat上velocity.log (Permission denied)解决

醉酒当歌 提交于 2019-12-03 17:49:11
起因: 自己在搭建一个关于 EVE Online 游戏 的网站,框架用的是Jfinal的,页面模板用的是velocity,在自己开发环境上一切正常,然后部署到线上环境后出现错误。线上的环境是Ubuntu14+Nginx+Mysql+Tomcat。 错误: Caused by: java.io.FileNotFoundException: velocity.log (Permission denied) 定位: 网上也有类似许多的问题,也有分析,我就不细说。总结起来就是: 1.使用时没有设置velocity log的任何参数,因为系统中存在Log4j的包,所以会使用Log4jChute做为Log记录的对象返回。 2.在初始化Log4jChute时,没有设置logger.name,初始化Logger时,会使用默认的velocity.log做为文件输出路径 3.File file = new File("velocity.log"),是基于当前jvm的current work,也就是user.dir属性。 而我又是将运行web跑在普通用户权限,但是安装tomcat是Root,所以权限出错。 所以第一次访问网站页面的时候当渲染页面时候,Velocity就会尝试建立日志,但是由于上面的问题无法创建。 解决方案 1.建立velocity的配置文件。(由于我也是第一次使用

Velocity找不到模板

被刻印的时光 ゝ 提交于 2019-12-03 17:49:01
最近工作中需要用到模板解析的功能,找到了velocity,按照例子做了一遍,没有问题, 于是乎,直接用于工作环境,发现总是报Resource not found 的异常, 检查模板路径,并没有写错什么,但是总是报这个异常,模板换了N个位置,还是报此异常 后来抛弃 Velocity.init(); Template template = Velocity.getTemplate("container.htm"); 改为: VelocityEngine velocityEngine = new VelocityEngine(); Properties properties = new Properties(); String basePath = “路径/windows/tlp”; properties.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, basePath); velocityEngine.init(properties); Template template = Velocity.getTemplate("container.htm"); 就可以了 看了一下文档,Velocity允许两种方式: 1、全局使用一个Velocity引擎(jvm中只有一个Velocity引擎的实例),适应于配置文件等解析(路径是一致的) 2

[翻译]使用 Velocity 构建一个web应用

醉酒当歌 提交于 2019-12-03 17:48:35
作为JSP的替代方案,Velocity 经常被用来在应用中生成web页面。使用Velocity生成页面的一些好处有: Simplicity - 页面可以被非技术型的web设计师创作和维护了。 Ease of maintainance – 脚本代码可以像MVC模式所要求的那样从web页面中移除了。 Access both methods and properties - web设计师可以在一个Context中引用方法和属性对象了。 Consistency - Velocity能够被用来执行其他类型的文本生成任务(比如发送邮件),从而提供一种一致的文本信息格式配置。 本文档提供一些关于在web应用中使用Velocity的入门信息。 使用一个框架 原始的使用Velocity引擎的目标是根据模板生成文本。所以Velocity中本身并没有包含任何和web相关的功能。为了让一个web应用起作用,你需要一个框架去回应HTTP请求、控制用户认证、调用业务逻辑,然后生成响应。下面是一些强大的竞争者。 1、Velocity Tools / VelocityViewServlet - 入门最简单的办法是下载相关 Velocity Tools 子项目,使用里面的VelocityViewServlet。 配置和安装这个servlet是容易的。在你的web服务器上面创建一个放模板文件的文件夹

基于Velocity的Web开发指南

耗尽温柔 提交于 2019-12-03 17:48:18
原文名称《Web Application Guide》,副标题为基于Web的应用技术和VelocityViewServlet入门,地址为 此处链接 。文章分为四部分,第一部分,通览使用Velocity创建Web应用的好处,第二部分,讲述需要使用的具体框架,第三部分,主要探讨使用Velocity时的问题,第四部分,讲解一个入门实例。 使用Velocity创建Web应用 Velocity通常被用来生成web页面,可以直接替代JSP,以下是使用Velocity的好处: 简单 - 不懂技术的网页设计者可以直接使用和维护。 易于维护 - 不包含脚本语言? 直接访问方法和属性 - 网页设计者也可以访问对象的方法和属性。 一致性 - Velocity不仅可以生成网页,也可以完成其他文本生成任务(如邮件发送)。 配合使用的具体框架 Velocity引擎的主要目的仅仅是为了生成文本,而且在模板基础上生成。因此,Velocity自己不包含任何web相关的功能,所以,我们还是需要一个框架来响应HTTP请求、来处理用户认证、来形成业务逻辑调用、以至形成响应,以下列出几个好的选择: 1. Velocity工具之一:VelocityViewServlet(Velocity视图服务器小程序) - 最简单的开始使用 Velocity的方法是下载 Velocity Tools 并使用

IntelliJ IDEA override $user

痴心易碎 提交于 2019-12-03 15:01:02
It's a quite simple question, but I can't find an answer to it using SO-Search and Google. Is it possible to override the default $user VTL-variable used in file-templates globally, instead of setting it in each template with #set($user = "...") ? Like some sort of setup-script for IntelliJ itself, where I can alter the value? Thanks in advance. By the way, I'm using IntelliJ Ultimate 12.1.6. Pr0gr4mm3r You want to modify the IntelliJ's .vmoptions file(s) in a text editor. In Windows, edit IntelliJ-Install-Location/bin/idea.exe.vmoptions and/or IntelliJ-Install-Location/bin/idea64.exe

使用nlv进行web开发 —— 第一篇:安装Tengine+LuaJIT

老子叫甜甜 提交于 2019-12-03 14:19:27
nlv架构目前只支持linux,最好是64位linux,比如fedora19,centOS6.4 安装系统所需web软件 1.下载luajit,官网 http://luajit.org/ wget http://luajit.org/download/LuaJIT-2.0.1.tar.gz tar xzvf LuaJIT-2.0.1.tar.gz cd LuaJIT-2.0.1 make PREFIX=/usr/local/web/LuaJIT-2.0.1 make install PREFIX=/usr/local/web/LuaJIT-2.0.1 2.下载最新版tengine,官网 http://tengine.taobao.org/ wget http://tengine.taobao.org/download/tengine-1.5.2.tar.gz tar xzvf tengine-1.5.2.tar.gz cd tengine-1.5.2 ./configure --with-ld-opt="-Wl,-rpath,/usr/local/web/LuaJIT-2.0.1/lib" --prefix=/usr/local/web/tengine-1.5.2 --with-http_lua_module --with-luajit-inc=/usr/local/web

Velocity Templates - New Line

荒凉一梦 提交于 2019-12-03 10:36:21
I've been working with Apache's Velocity engine and a custom template. The thing is, that I haven't been able to generate a String with the corresponding line breaks. I tried almost everything that I found, such as using $esc.n and $esc.newline (I'm already using escape tools on my project) but it seems that the version I'm currently using doesn't support it (1.4), checked if putting '\n', '\\n' and even '\\\n' would work, but same thing. Does anyone have any solution to this? We had issues with newlines and ended up putting a property on the VelocityContext: VelocityContext ctx = new

Replace a Substring of a String in Velocity Template Language

巧了我就是萌 提交于 2019-12-03 10:34:20
问题 I want to replace a part of a string in Velocity Template Language with another string. For Example: #set($a = "Hello") #set($b = "+") I want to replace ll in Hello with ++. The output should be He++o Please help me Thanks Kishore 回答1: By default you can use the methods of the Java String object: #set( $a = "Hello" ) #set( $b = $a.replace("l", "+") ) ${b} will produce He++o and you can also use velocity variables as arguments to your method calls, e.g.: #set( $a = "Hello" ) #set( $b = "+" )

OpenMP/C++: Parallel for loop with reduction afterwards - best practice?

匿名 (未验证) 提交于 2019-12-03 10:10:24
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Given the following code... for (size_t i = 0; i < clusters.size(); ++i) { const std::set<int>& cluster = clusters[i]; // ... expensive calculations ... for (int j : cluster) velocity[j] += f(j); } ...which I would like to run on multiple CPUs/cores. The function f does not use velocity . A simple #pragma omp parallel for before the first for loop will produce unpredictable/wrong results, because the std::vector<T> velocity is modified in the inner loop. Multiple threads may access and (try to) modify the same element of velocity at the same