I have a maven dependency jar that requires access to -DmyProperty=foo
. When I start my application my main project can access the myProperty value. However the classes within the dependency jar (also a maven project) is unable to access these using System.getProperty()
and returns null
value. I was under the impression that every class on the class path had access to these resources. Is there a good way to get these values passed back to the dependency jar? If it makes a difference, both projects are built on spring.
The dependency jar uses:
import org.springframework.core.env.Environment;
@Autowired
private Environment environment;
public class myClass{
...
public void myFunction() throws Throwable {
System.out.println("System Env: " + environment.getProperty("myProperty"));
}
The main project imports the above project and creates a new instance of the above class and runs myFunction but blows up with a null pointer on environmnt.getProperty()
.
Any help is appreciated.