<s>[INST] Here is a code in Java that uses Spring Boot to build a web application. 

```java
@SpringBootApplication
public class Application {

    @Autowired
    private YearlyPlanRepository yearlyPlanRepository;

    @Bean
    public SessionFactory sessionFactory() {
        return new LocalSessionFactoryBuilder(dataSource())
                .addAnnotatedClasses(YearlyPlan.class)
                .buildSessionFactory();
    }

    @Bean
    public DataSource dataSource() {
        BasicDataSource dataSource = new BasicDataSource();
        dataSource.setDriverClassName("com.mysql.jdbc.Driver");
        dataSource.setUrl("jdbc:mysql://localhost:3306/pfm");
        dataSource.setUsername("root");
        dataSource.setPassword("root");
        dataSource.setInitialSize(5);
        dataSource.setMaxActive(10);
        return dataSource;
    }

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}
```
I would like to know if it's possible and how I can externalize the database credentials (host, port, database, username, password) to a .properties file so they can be easily changed without modifying the code. 

Also, how can I manage different environments (dev, qa, prod) with different database credentials?[/INST]