Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 将控制台的输出获取到localhost:8080_Java_Mongodb_Spring Boot - Fatal编程技术网

Java 将控制台的输出获取到localhost:8080

Java 将控制台的输出获取到localhost:8080,java,mongodb,spring-boot,Java,Mongodb,Spring Boot,如何将控制台的输出正确地输入浏览器。我曾参与过其他一些小型spring mvc restful web服务项目,并且我能够顺利地在localhost:8080/上确定日期,我只是想知道为什么我会使用这个项目 以下是一些输出: Customer: Customer [userId=1, forename=homer, lastname=simpson, email=hsimpson@springfield.com, mobileNumber=0781 123 456, password=marge

如何将控制台的输出正确地输入浏览器。我曾参与过其他一些小型spring mvc restful web服务项目,并且我能够顺利地在localhost:8080/上确定日期,我只是想知道为什么我会使用这个项目

以下是一些输出:

Customer: Customer [userId=1, forename=homer, lastname=simpson, email=hsimpson@springfield.com, 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]]], 
或者

   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

以下是BackendServiceImpl类:

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", "hsimpson@springfield.com", "0781 123 456", "marge");

        addCustomer("ned", "flanders", "nflanders@springfield.com", "0781 777 888", "maude");

        addCustomer("monty", "burns", "mburns@springfield.com", "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);       
    }


}
public类backendserviceinpl实现BackendService{
私有静态最终字符串[]书名=新字符串[]{“傻瓜指南”,“释放猎犬”,“如何快乐”};
私人静态最终浮动[]账面价格=新浮动[]{10.45f,22.00f,5.50f};
private static final String[]bookAuthors=新字符串[]{“人马”、“鲁弗斯·拉夫”、“奥纳·阿皮”};
私有静态最终随机=新随机();
私有静态最终列表bookList=newarraylist();
静止的{
对于(int index=0;index
无法通过这种方式访问Web服务器日志,您也不希望这样做。此外,如果服务器仅在本地主机上运行,则只有运行web服务器的计算机才能访问web服务器


很难说你在这里想要实现什么,你的人际网络是什么样的。我假设您在一台机器上运行一个web服务器,并且您试图从另一台机器访问它。您需要提供更多信息。

大家好,祝您愉快,欢迎来到Stack Overflow。很抱歉告诉你这个问题,但是你的问题不太容易回答,你需要把它提高到标准。首先,您需要提供的不是所有的代码,而是一个简单的代码;另一方面,你需要准确地描述你在尝试什么,以及你这样做的时候出了什么问题。没有这些,你要求人们检查你的整个代码,找出它在尝试做什么,以及可能出了什么问题,并提出修改建议。这将是一个完整的代码检查,并不是这个网站真正的主题;看一看
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", "hsimpson@springfield.com", "0781 123 456", "marge");

        addCustomer("ned", "flanders", "nflanders@springfield.com", "0781 777 888", "maude");

        addCustomer("monty", "burns", "mburns@springfield.com", "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);       
    }


}