Skip to content
Snippets Groups Projects
Commit 00ba465b authored by Andy Großhennig's avatar Andy Großhennig
Browse files

Underworld

parent dffe3e85
No related branches found
No related tags found
1 merge request!2Underworld
......@@ -25,7 +25,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
......
package se2.demo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -7,15 +9,23 @@ import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
@RestController
public class HelloworldApplication {
public class HelloworldApplication implements CommandLineRunner{
@Autowired
private WorldRepository wr;
public static void main(String[] args) {
SpringApplication.run(HelloworldApplication.class, args);
}
@Override
public void run(String... args) {
//wr.save(new World("Sol"));
//System.out.println(wr.findByStar("Sol").get(0));
}
@GetMapping("/")
public String hello() {
return "Hello World!";
return "Hello Underworld!";
}
}
package se2.demo;
import org.springframework.data.annotation.Id;
public class World {
@Id
public String id;
public String star;
public World(String star) {
this.star = star;
}
}
package se2.demo;
import org.springframework.data.mongodb.repository.MongoRepository;
import java.util.List;
public interface WorldRepository extends MongoRepository<World, String>{
public List<World> findByStar(String star);
}
spring.application.name=helloworld
spring.data.mongodb.host=localhost
spring.data.mongodb.port=27017
spring.data.mongodb.database=Worlds
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment