So erhalten Sie die Ausgabe von der Konsole in den Browser https://localhost:8080/. Ich arbeitete an einem anderen kleinen Frühling Mvc erholsamen Web-Service-Projekt und ich war problemlos in der Lage, das Datum auf localhost: 8080/Ich frage mich nur, warum ich Katze mit diesem Projekt.Abrufen der Ausgabe von der Konsole in localhost: 8080
Hier einige der Ausgabe:
Customer: Customer [userId=1, forename=homer, lastname=simpson, [email protected], mobileNumber=0781 123 456, password=marge, orders=[
Order [orderId=0 total Order cost: 86.9, orderItems=[
OrderItem [item=Item [title=Dummies Guide to Dummies, publisher=Red Penguin, price=10.45, yearPublished=2014] Book [author=Man Equine], count=2 total cost=20.9],
OrderItem [item=Item [title=Release the hounds, publisher=Red Penguin, price=22.0, yearPublished=2014] Book [author=Rufus Ruff], count=3 total cost=66.0]]],
Entweder
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Wed Mar 22 23:20:49 EET 2017
There was an unexpected error (type=Not Found, status=404).
No message available
Oder
Firefox can't establish a connection to the server at localhost:8080.
Hier ist die BackendServiceImpl Klasse:
public class BackendServiceImpl implements BackendService {
private static final String[] bookTitles = new String[]{"Dummies Guide to Dummies","Release the hounds","How to be happy"};
private static final float[] bookPrice = new float[]{10.45f, 22.00f, 5.50f};
private static final String[] bookAuthors = new String[]{"Man Equine","Rufus Ruff","Oona Appy"};
private static final Random random = new Random();
private static final List<Book> bookList = new ArrayList<Book>();
static {
for (int index = 0; index < bookTitles.length; index++) {
bookList.add(createBook(index));
}
}
private Map<Integer, Customer> customers = new ConcurrentHashMap<Integer, Customer>();
private Map<Integer, Order> orders = new ConcurrentHashMap<Integer, Order>();
private AtomicInteger customerIdCounter = new AtomicInteger();
private AtomicInteger orderIdCounter = new AtomicInteger();
public BackendServiceImpl() {
initialiseCustomers();
}
private static Book createBook(int index) {
final Book book = new Book(bookTitles[index], "Red Penguin", bookPrice[index], 2014, bookAuthors[index]);
return book;
}
private OrderItem createOrderItem() {
int index = random.nextInt(bookTitles.length);
final Book book = bookList.get(index);
final OrderItem orderItem = new OrderItem(book);
final int quantity = random.nextInt(3);
for(int c = 0; c < quantity; c++) {
orderItem.incrementQuantity();
}
return orderItem;
}
private Order createOrder() {
final Order order = new Order();
final int numberOrderItems = random.nextInt(2) + 1;
Set<OrderItem> set = new HashSet<OrderItem>();
int count = set.size();
while(count < numberOrderItems) {
set.add(createOrderItem());
count = set.size();
}
order.setOrderItems(new ArrayList<OrderItem>(set));
final int index = orderIdCounter.getAndIncrement();
order.setOrderId(index);
orders.put(index, order);
return order;
}
private List<Order> createCustomerOrders() {
final int numberOrders = random.nextInt(3) + 1;
final List<Order> orders = new ArrayList<Order>();
for (int index = 0; index < numberOrders; index++) {
orders.add(createOrder());
}
return orders;
}
private int addCustomer(final String firstName, final String lastName, final String email, final String mobileNumber, final String password) {
final Customer customer = new Customer(firstName, lastName, email, mobileNumber, password);
int id = customerIdCounter.incrementAndGet();
customer.setUserId(id);
final List<Order> customerOrders = createCustomerOrders();
for(Order order : customerOrders) {
customer.addOrder(order);
}
customers.put(id, customer);
return id;
}
private void initialiseCustomers() {
addCustomer("homer", "simpson", "[email protected]", "0781 123 456", "marge");
addCustomer("ned", "flanders", "[email protected]", "0781 777 888", "maude");
addCustomer("monty", "burns", "[email protected]", "0781 $$$ $$$", "release the hounds");
}
@Override
public List<Customer> getAllCustomers() {
List<Customer> customersList = new ArrayList<Customer>(customers.values());
return customersList;
}
@Override
public Customer getCustomer(int customerId) {
return customers.get(customerId);
}
@Override
public List<Order> getCustomerOrders(int customerId) {
final Customer customer = customers.get(customerId);
return customer.getOrders();
}
@Override
public Order getOrder(int orderId) {
return orders.get(orderId);
}
public static void main (final String[] args) {
final BackendService service = new BackendServiceImpl();
final Customer customer = service.getCustomer(1);
System.out.println("Customer: " + customer);
}
@Override
public int createCustomer(Customer customer) {
return addCustomer(customer.getForename(), customer.getLastname(), customer.getEmail(), customer.getMobileNumber(), customer.getPassword());
}
@Override
public void deleteCustomer(int id) {
customers.remove(id);
}
}
Hallo Be -.- Glücklich, und willkommen zu Stack Overflow. Es tut mir leid, Ihnen das zu sagen, aber Ihre Frage ist nicht sehr einfach zu beantworten, und Sie müssen sie [bearbeiten], um sie auf den Standard zu bringen. Zum einen müssen Sie nicht Ihren gesamten Code bereitstellen, sondern nur ein [minimales, vollständiges und überprüfbares Beispiel] (https://stackoverflow.com/help/mcve); Zum anderen müssen Sie genau beschreiben, was Sie versuchen und was schief geht, wenn Sie das tun. –
Ohne dass Sie die Leute bitten, Ihren gesamten Code zu überprüfen, herauszufinden, was es zu tun versucht und wie es schief gehen könnte, und Änderungen zu empfehlen. Das wäre eine vollständige Code-Überprüfung, und ist nicht wirklich Thema zu diesem Thema Seite? ˅; werfen Sie einen Blick auf die [Anleitung] (http://stackoverflow.com/help/on-topic) –