当前位置: 首页>>代码示例>>Java>>正文


Java FreeMarkerConfigurationFactoryBean类代码示例

本文整理汇总了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;
}
 
开发者ID:QianmiOpen,项目名称:interface-test,代码行数:9,代码来源:InterfaceTestApplication.java

示例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()));
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:27,代码来源:FreeMarkerConfigurerTests.java

示例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();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:10,代码来源:FreeMarkerConfigurerTests.java

示例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);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:9,代码来源:FreeMarkerConfigurerTests.java

示例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()));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:28,代码来源:FreeMarkerConfigurerTests.java

示例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();
}
 
开发者ID:xenit-eu,项目名称:move2alf,代码行数:9,代码来源:FreemarkerCheckTool.java

示例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
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:15,代码来源:FreeMarkerConfigurerTests.java

示例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);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:8,代码来源:FreeMarkerConfigurerTests.java

示例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();
}
 
开发者ID:alv-ch,项目名称:alv-ch-sysinfos.api,代码行数:8,代码来源:MailConfiguration.java

示例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);
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:40,代码来源:HeatTemplateBuilderTest.java

示例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();
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:8,代码来源:EmailSenderHostServiceTypeTest.java

示例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);
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:15,代码来源:UserDataBuilderTest.java

示例14: freemarkerMailConfiguration

import org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean; //导入依赖的package包/类
@Bean
public FreeMarkerConfigurationFactoryBean freemarkerMailConfiguration() {
	FreeMarkerConfigurationFactoryBean configuration = new FreeMarkerConfigurationFactoryBean();
	configuration.setTemplateLoaderPath("classpath:notification");
	return configuration;
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:7,代码来源:BasicApplicationCoreNotificationConfig.java

示例15: freeMarkerConfigurationFactoryBean

import org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean; //导入依赖的package包/类
@Bean public FreeMarkerConfigurationFactoryBean freeMarkerConfigurationFactoryBean() {
  FreeMarkerConfigurationFactoryBean configurationBean = new FreeMarkerConfigurationFactoryBean();
  configurationBean.setTemplateLoaderPath("classpath:/print");

  return configurationBean;
}
 
开发者ID:tunguski,项目名称:matsuo-core,代码行数:7,代码来源:GeneralConfig.java


注:本文中的org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。