Skip to content

Commit f87dce9

Browse files
committed
Log default resources
Closes gh-62
1 parent 4237599 commit f87dce9

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

spring-boot-testjars/src/main/java/org/springframework/experimental/boot/server/exec/CommonsExecWebServerFactoryBean.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import java.util.function.Consumer;
2424

2525
import org.apache.commons.exec.CommandLine;
26+
import org.apache.commons.logging.Log;
27+
import org.apache.commons.logging.LogFactory;
2628

2729
import org.springframework.beans.factory.BeanNameAware;
2830
import org.springframework.beans.factory.DisposableBean;
@@ -42,6 +44,8 @@
4244
public class CommonsExecWebServerFactoryBean
4345
implements SmartFactoryBean<CommonsExecWebServer>, DisposableBean, BeanNameAware {
4446

47+
private static Log logger = LogFactory.getLog(CommonsExecWebServerFactoryBean.class);
48+
4549
private static final String DEFAULT_SPRING_BOOT_MAIN_CLASSNAME = "org.springframework.experimental.boot.server.exec.main.SpringBootApplicationMain";
4650

4751
private String executable = currentJavaExecutable();
@@ -150,11 +154,22 @@ public void setBeanName(String beanName) {
150154
}
151155

152156
private void defaultApplicationConfiguration(String beanName, String extension) {
153-
ResourceClasspathEntry defaultApplicationConfig = new ResourceClasspathEntry(
154-
"testjars/" + beanName + "/application." + extension, "application." + extension);
157+
String existingResourceName = "testjars/" + beanName + "/application." + extension;
158+
String classpathResourceName = "application." + extension;
159+
ResourceClasspathEntry defaultApplicationConfig = new ResourceClasspathEntry(existingResourceName,
160+
classpathResourceName);
155161
if (defaultApplicationConfig.exists()) {
162+
if (logger.isDebugEnabled()) {
163+
logger.debug("Adding default resource " + existingResourceName + " as " + classpathResourceName);
164+
}
156165
classpath((cp) -> cp.entries(defaultApplicationConfig));
157166
}
167+
else {
168+
if (logger.isDebugEnabled()) {
169+
logger.debug("The default resource was not found " + existingResourceName
170+
+ " and will not be added to the classpath as " + classpathResourceName);
171+
}
172+
}
158173
}
159174

160175
@Override

0 commit comments

Comments
 (0)