My SpringBoot 2.0.3 java 8 program works fine on Eclipse Photon (using Maven), however, when I build it into a jar file and install on AWS Linux and run there I get:
2019-06-10 10:07:14.395 WARN 18316 --- [ main]s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ccWrapperApplication': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'tmp.dir' in value "${tmp.dir}"
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ccWrapperApplication': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'tmp.dir' in value "${tmp.dir}"
so it looks like spring can't find the application.properties vars when running on Linux. Why not?
tmp.dir is defined in src/main/resources/application.properties as:
tmp.dir=tmp
and ccWrapperApplication.java has:
@SpringBootApplication
// SpringBoot likes to use a database, we don't need one, so we exclude the default dB.
@EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class, HibernateJpaAutoConfiguration.class})
public class CcWrapperApplication implements CommandLineRunner {
@Value("${tmp.dir}")
public String tmpDir;
public static void main(String[] args) {
logger.info("running CcWrapperApplication on " + System.getProperty("os.name"))
SpringApplication.run(CcWrapperApplication.class, args);
}
@Override
public void run(String... args) {
...
}
public String getTmpDir() {
return tmpDir;
}
public void setTmpDir(String tmpDir) {
this.tmpDir = tmpDir;
}
}
I built the application jar using eclipse: export->Runnable JAR file
Installed the jar on Linux, added the jar to the CLASSPATH (and all the SpringBoot jars) and ran from a shell script using:
java com.clarivate.singulatiry.chemworkbench.chemcurator.chemcurator_wrapper.CcWrapperApplication $inputDir $outputDir 2>&1 >>$logfile | tee -a $logfile >>$errorfile
Any help appreciated.