-1

In MacOS, they just open terminal and do these

vi .bash_profile

here vi is something like text editor ..

then the file named .bash_profile popsup and they store

export envVerNum=2.2.2 

and save it and close it.

then open terminal again and type

echo $envVerNum

it returns 2.2.2 ! it also returns in sts4 !

Now, Whats the process in Windows ! Please explain me as i am noob to this Spring Boot !

I tried this ...

here's the application Properties !

spring.thymeleaf.cache=false #just for example
version=${envVerNum}

Here's the HomeController !

@Controller
public class homeController {
    @Value("${version}")
    private String ver;
    @RequestMapping("/")
    public String diaplayHome(Model model) throws JsonProcessingException {
        model.addAttribute("venum", ver);
        return "Home/home";
    }
}

here's the Home html code ...

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title>Home !</title>
    <div th:replace="layouts::hey1"></div>
</head>
<body>
    <nav th:replace="layouts::hey"></nav>
    <div class="container">
        <h3>Main Dashboard</h3>
        <a th:text="${venum}"></a>
        <hr>
</body>
</html>

I want to set the envVerNum and call it inside the Sts4... please help me with windows !

1 Answers1

0

I think the term you are looking for is environment variables. When you reference something as '${envVerNum}' it is expected that you have it defined somewhere within your environment (this can be a .properties file, this can be defined as an environment variable on the machine as well etc).

Im not sure how STS4 works but IntelliJ has a very convenient option for setting Environment Variables as part of run configurations.

I assume STS should have something similar. You can read about how its done in intellij here:

IntelliJ Run Config Environment Variables

Ultimately if STS does not provide such an option, you can look into adding environment variables on windows:

Windows Environment Variables Guide

benjaminv2
  • 109
  • 8