本文整理汇总了Java中org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean类的典型用法代码示例。如果您正苦于以下问题:Java FreeMarkerConfigurationFactoryBean类的具体用法?Java FreeMarkerConfigurationFactoryBean怎么用?Java FreeMarkerConfigurationFactoryBean使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FreeMarkerConfigurationFactoryBean类属于org.springframework.ui.freemarker包,在下文中一共展示了FreeMarkerConfigurationFactoryBean类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: freeMarkerConfiguration
import org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean; //导入依赖的package包/类
@Bean
public FreeMarkerConfigurationFactoryBean freeMarkerConfiguration() {
FreeMarkerConfigurationFactoryBean freeMarkerFactoryBean = new FreeMarkerConfigurationFactoryBean();
freeMarkerFactoryBean.setTemplateLoaderPaths("classpath:/templates");
freeMarkerFactoryBean.setPreferFileSystemAccess(true);
freeMarkerFactoryBean.setDefaultEncoding("UTF-8");
return freeMarkerFactoryBean;
}
示例2: testFreemarkerConfigurationFactoryBeanWithNonFileResourceLoaderPath
import org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean; //导入依赖的package包/类
public void testFreemarkerConfigurationFactoryBeanWithNonFileResourceLoaderPath()
throws IOException, TemplateException {
FreeMarkerConfigurationFactoryBean fcfb = new FreeMarkerConfigurationFactoryBean();
fcfb.setTemplateLoaderPath("file:/mydir");
Properties settings = new Properties();
settings.setProperty("localized_lookup", "false");
fcfb.setFreemarkerSettings(settings);
fcfb.setResourceLoader(new ResourceLoader() {
@Override
public Resource getResource(String location) {
if (!("file:/mydir".equals(location) || "file:/mydir/test".equals(location))) {
throw new IllegalArgumentException(location);
}
return new ByteArrayResource("test".getBytes(), "test");
}
@Override
public ClassLoader getClassLoader() {
return getClass().getClassLoader();
}
});
fcfb.afterPropertiesSet();
assertThat(fcfb.getObject(), instanceOf(Configuration.class));
Configuration fc = fcfb.getObject();
Template ft = fc.getTemplate("test");
assertEquals("test", FreeMarkerTemplateUtils.processTemplateIntoString(ft, new HashMap()));
}
示例3: freeMarkerConfigurationFactoryBeanWithConfigLocation
import org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean; //导入依赖的package包/类
@Test(expected = IOException.class)
public void freeMarkerConfigurationFactoryBeanWithConfigLocation() throws Exception {
FreeMarkerConfigurationFactoryBean fcfb = new FreeMarkerConfigurationFactoryBean();
fcfb.setConfigLocation(new FileSystemResource("myprops.properties"));
Properties props = new Properties();
props.setProperty("myprop", "/mydir");
fcfb.setFreemarkerSettings(props);
fcfb.afterPropertiesSet();
}
示例4: freeMarkerConfigurationFactoryBeanWithResourceLoaderPath
import org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean; //导入依赖的package包/类
@Test
public void freeMarkerConfigurationFactoryBeanWithResourceLoaderPath() throws Exception {
FreeMarkerConfigurationFactoryBean fcfb = new FreeMarkerConfigurationFactoryBean();
fcfb.setTemplateLoaderPath("file:/mydir");
fcfb.afterPropertiesSet();
Configuration cfg = fcfb.getObject();
assertTrue(cfg.getTemplateLoader() instanceof SpringTemplateLoader);
}
示例5: freeMarkerConfigurationFactoryBeanWithNonFileResourceLoaderPath
import org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean; //导入依赖的package包/类
@Test
@SuppressWarnings("rawtypes")
public void freeMarkerConfigurationFactoryBeanWithNonFileResourceLoaderPath() throws Exception {
FreeMarkerConfigurationFactoryBean fcfb = new FreeMarkerConfigurationFactoryBean();
fcfb.setTemplateLoaderPath("file:/mydir");
Properties settings = new Properties();
settings.setProperty("localized_lookup", "false");
fcfb.setFreemarkerSettings(settings);
fcfb.setResourceLoader(new ResourceLoader() {
@Override
public Resource getResource(String location) {
if (!("file:/mydir".equals(location) || "file:/mydir/test".equals(location))) {
throw new IllegalArgumentException(location);
}
return new ByteArrayResource("test".getBytes(), "test");
}
@Override
public ClassLoader getClassLoader() {
return getClass().getClassLoader();
}
});
fcfb.afterPropertiesSet();
assertThat(fcfb.getObject(), instanceOf(Configuration.class));
Configuration fc = fcfb.getObject();
Template ft = fc.getTemplate("test");
assertEquals("test", FreeMarkerTemplateUtils.processTemplateIntoString(ft, new HashMap()));
}
示例6: freeMarkerConfiguration
import org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean
public FreeMarkerConfigurationFactoryBean freeMarkerConfiguration() {
FreeMarkerConfigurationFactoryBean freeMarkerFactoryBean = new FreeMarkerConfigurationFactoryBean();
applyProperties(freeMarkerFactoryBean);
return freeMarkerFactoryBean;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:FreeMarkerAutoConfiguration.java
示例7: FreemarkerCheckTool
import org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean; //导入依赖的package包/类
public FreemarkerCheckTool(final String templateLoaderPath)
throws Exception {
final FreeMarkerConfigurationFactoryBean fmCfgFactory = new FreeMarkerConfigurationFactoryBean();
fmCfgFactory.setTemplateLoaderPaths(new String[] { templateLoaderPath,
SPRING_FTL_LOADER_PATH });
fmCfgFactory.afterPropertiesSet();
freemarkerConfiguration = fmCfgFactory.getObject();
}
示例8: testFreemarkerConfigurationFactoryBeanWithConfigLocation
import org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean; //导入依赖的package包/类
public void testFreemarkerConfigurationFactoryBeanWithConfigLocation() throws TemplateException {
FreeMarkerConfigurationFactoryBean fcfb = new FreeMarkerConfigurationFactoryBean();
fcfb.setConfigLocation(new FileSystemResource("myprops.properties"));
Properties props = new Properties();
props.setProperty("myprop", "/mydir");
fcfb.setFreemarkerSettings(props);
try {
fcfb.afterPropertiesSet();
fail("Should have thrown IOException");
}
catch (IOException ex) {
// expected
}
}
示例9: testFreeMarkerConfigurationFactoryBeanWithResourceLoaderPath
import org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean; //导入依赖的package包/类
public void testFreeMarkerConfigurationFactoryBeanWithResourceLoaderPath() throws Exception {
FreeMarkerConfigurationFactoryBean fcfb = new FreeMarkerConfigurationFactoryBean();
fcfb.setTemplateLoaderPath("file:/mydir");
fcfb.afterPropertiesSet();
Configuration cfg = fcfb.getObject();
assertTrue(cfg.getTemplateLoader() instanceof SpringTemplateLoader);
}
示例10: freemarkerConfiguration
import org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean; //导入依赖的package包/类
@Bean
public freemarker.template.Configuration freemarkerConfiguration() {
FreeMarkerConfigurationFactoryBean factoryBean = new FreeMarkerConfigurationFactoryBean();
factoryBean.setPreferFileSystemAccess(false);
factoryBean.setTemplateLoaderPath("classpath:/");
return factoryBean.getObject();
}
示例11: setup
import org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean; //导入依赖的package包/类
@Before
public void setup() throws IOException, TemplateException {
initMocks(this);
FreeMarkerConfigurationFactoryBean factoryBean = new FreeMarkerConfigurationFactoryBean();
factoryBean.setPreferFileSystemAccess(false);
factoryBean.setTemplateLoaderPath("classpath:/");
factoryBean.afterPropertiesSet();
Configuration configuration = factoryBean.getObject();
ReflectionTestUtils.setField(heatTemplateBuilder, "freemarkerConfiguration", configuration);
ReflectionTestUtils.setField(heatTemplateBuilder, "openStackHeatTemplatePath", templatePath);
stackName = "testStack";
groups = new ArrayList<>(1);
String name = "master";
List<Volume> volumes = Arrays.asList(new Volume("/hadoop/fs1", "HDD", 1), new Volume("/hadoop/fs2", "HDD", 1));
InstanceTemplate instanceTemplate = new InstanceTemplate("m1.medium", name, 0L, volumes, InstanceStatus.CREATE_REQUESTED,
new HashMap<>(), 0L);
InstanceAuthentication instanceAuthentication = new InstanceAuthentication("sshkey", "", "cloudbreak");
CloudInstance instance = new CloudInstance("SOME_ID", instanceTemplate, instanceAuthentication);
List<SecurityRule> rules = Collections.singletonList(new SecurityRule("0.0.0.0/0",
new PortDefinition[]{new PortDefinition("22", "22"), new PortDefinition("443", "443")}, "tcp"));
Security security = new Security(rules, null);
groups.add(new Group(name, InstanceGroupType.CORE, Collections.singletonList(instance), security, null,
instanceAuthentication, instanceAuthentication.getLoginUserName(), instanceAuthentication.getPublicKey()));
Map<InstanceGroupType, String> userData = ImmutableMap.of(
InstanceGroupType.CORE, "CORE",
InstanceGroupType.GATEWAY, "GATEWAY"
);
Map<String, String> tags = new HashMap<>();
tags.put(CloudbreakResourceType.DISK.templateVariable(), CloudbreakResourceType.DISK.key());
tags.put(CloudbreakResourceType.INSTANCE.templateVariable(), CloudbreakResourceType.INSTANCE.key());
tags.put(CloudbreakResourceType.IP.templateVariable(), CloudbreakResourceType.IP.key());
tags.put(CloudbreakResourceType.NETWORK.templateVariable(), CloudbreakResourceType.NETWORK.key());
tags.put(CloudbreakResourceType.SECURITY.templateVariable(), CloudbreakResourceType.SECURITY.key());
tags.put(CloudbreakResourceType.STORAGE.templateVariable(), CloudbreakResourceType.STORAGE.key());
tags.put(CloudbreakResourceType.TEMPLATE.templateVariable(), CloudbreakResourceType.TEMPLATE.key());
when(defaultCostTaggingService.prepareInstanceTagging()).thenReturn(tags);
image = new Image("cb-centos66-amb200-2015-05-25", userData, "redhat6", "url", "default", null);
}
示例12: freemarkerConfiguration
import org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean; //导入依赖的package包/类
Configuration freemarkerConfiguration() throws IOException, TemplateException {
FreeMarkerConfigurationFactoryBean factoryBean = new FreeMarkerConfigurationFactoryBean();
factoryBean.setPreferFileSystemAccess(false);
factoryBean.setTemplateLoaderPath("classpath:/");
factoryBean.afterPropertiesSet();
return factoryBean.getObject();
}
示例13: setup
import org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean; //导入依赖的package包/类
@Before
public void setup() throws IOException, TemplateException {
FreeMarkerConfigurationFactoryBean factoryBean = new FreeMarkerConfigurationFactoryBean();
factoryBean.setPreferFileSystemAccess(false);
factoryBean.setTemplateLoaderPath("classpath:/");
factoryBean.afterPropertiesSet();
Configuration configuration = factoryBean.getObject();
USER_DATA_BUILDER.setFreemarkerConfiguration(configuration);
UserDataBuilderParams params = new UserDataBuilderParams();
params.setCustomData("date >> /tmp/time.txt");
ReflectionTestUtils.setField(USER_DATA_BUILDER, "userDataBuilderParams", params);
}
示例14: freemarkerMailConfiguration
import org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean; //导入依赖的package包/类
@Bean
public FreeMarkerConfigurationFactoryBean freemarkerMailConfiguration() {
FreeMarkerConfigurationFactoryBean configuration = new FreeMarkerConfigurationFactoryBean();
configuration.setTemplateLoaderPath("classpath:notification");
return configuration;
}
示例15: freeMarkerConfigurationFactoryBean
import org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean; //导入依赖的package包/类
@Bean public FreeMarkerConfigurationFactoryBean freeMarkerConfigurationFactoryBean() {
FreeMarkerConfigurationFactoryBean configurationBean = new FreeMarkerConfigurationFactoryBean();
configurationBean.setTemplateLoaderPath("classpath:/print");
return configurationBean;
}