class path resource [config.properties}] cannot be opened because it does not exist

Schuriko

Bekanntes Mitglied
Ich teste gerade etwas mit @Value rum. Meine Dateien sehen wie folgt aus

Code:
@Configuration
@PropertySource("classpath:/config.properties}")
public class Config {

    @Value("#{'${text:Default Name}'}")
    private String name;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

in src/main/ressources existiert eine Datei "config.properties".
Code:
test=Dieses ist ein Test

Mein Test Funktion sieht wie folgt aus:
Code:
import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest
public class ConfigTest {

    @Before
    public void setUp() throws Exception {
    }

    @Test
    public void test() {
        Config config = new Config();
    
        assertEquals(config.getName(), "Dieses ist ein Test");
    }

}

Beim Ausführen erhalte ich allerdings die Fehlermeldung
Caused by: java.io.FileNotFoundException: class path resource [config.properties}] cannot be opened because it does not exist

Was mache ich gerad falsch?
 

Zurück
Oben