我已经写了一个基于Spring-boot,tomcat,freemarker的项目,我成功运行它,但每当我修改一些模板和java类时,我必须重新启动服务器或使用Intellij上的"reload changed classes"菜单使更改生效.这浪费了很多时间!
然后我尝试使用springloaded作为官方说:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
<version>1.2.0.RELEASE</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/springloaded-1.2.0.RELEASE.jar</systemPath>
</dependency>
</dependencies>
</plugin>
Run Code Online (Sandbox Code Playgroud)
然后我重新运行服务器,但没有按预期工作!在模板或类上进行任何更改后,我仍然需要重新启动服务器.
如何配置springloaded以自动重新加载.非常感谢!
Spring-boot的版本是1.3.0RC1
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.0.RC1</version>
</parent>
Run Code Online (Sandbox Code Playgroud)
maven版本:3.2 jdk:1.8 intellij:14.1.5 os:windows 8.1 64位
我想对Spring-boot进行Junit测试,如下所示:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {ApplicationTest.class})
public class TestOnSpring {
@Value("${app.name}")
private String appName;
@Test
public void testValue(){
System.out.println(appName);
}
}
Run Code Online (Sandbox Code Playgroud)
和ApplicationTest.java这样
@ComponentScan("org.nerve.jiepu")
@EnableAutoConfiguration()
public class ApplicationTest {
public static void main(String[] args) {
SpringApplication.run(ApplicationTest.class, args);
}
}
Run Code Online (Sandbox Code Playgroud)
我的POM是这样的:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.0.BUILD-SNAPSHOT</version>
</parent>
Run Code Online (Sandbox Code Playgroud)
当我运行测试时,我得到了以下错误信息
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'app.name' in string value "${app.name}"
at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:174)
at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:126)
at org.springframework.core.env.AbstractPropertyResolver.doResolvePlaceholders(AbstractPropertyResolver.java:204)
at org.springframework.core.env.AbstractPropertyResolver.resolveRequiredPlaceholders(AbstractPropertyResolver.java:178)
at org.springframework.context.support.PropertySourcesPlaceholderConfigurer$2.resolveStringValue(PropertySourcesPlaceholderConfigurer.java:172)
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveEmbeddedValue(AbstractBeanFactory.java:807)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1027)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:543)
... 31 more
Run Code Online (Sandbox Code Playgroud)
但是当我将此应用程序作为普通Java应用程序运行时
@SpringBootApplication
public …Run Code Online (Sandbox Code Playgroud)