Maven Project本地git存储库无法正常工作

时间:2015-08-03 14:17:05

标签: java eclipse git maven

我是eclipse和Git中maven项目的新手。 我创建了一个maven项目。它工作正常,直到我添加一个本地git存储库来在远程github上添加我的项目。 我的休息api不再有任何内容错误(没有找到资源)。

这是我的代码:

API:

SELECT STR_TO_DATE('15-jul-2015','%d-%M-%Y');

main.js

package com.gtu.project.quickpay;

import java.util.List;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import com.gtu.project.quickpay.services.AccountService;
import com.gtu.project.quickpay.services.CustomerService;
import com.gtu.project.quickpay.services.UserService;
import com.gtu.project.quickpay.models.Account;
import com.gtu.project.quickpay.models.Customer;
import com.gtu.project.quickpay.models.User;

@Path("myresource")
public class MyResource {

//get all accounts
@GET
@Produces(MediaType.APPLICATION_JSON)
public List<Account> getAllAccounts() {
    return AccountService.getAllAccounts();
}

@Path("createAccount")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Account createAccount(Account acc){
    Account account =  AccountService.createAccount(acc.getBalance(),acc.getPin(),acc.getCardId());
    return account;
}


@Path("createCustomer")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Customer createCustomer(Customer cus){
    Customer customer =  CustomerService.createCustomer(cus.getFirstName(),cus.getMiddleName(),
            cus.getLastName(),cus.getGender(),cus.getAddress(),cus.getPincode(),cus.getPhone(),
            cus.getEmail(),cus.getAccountId());
    return customer;
}

@Path("createUser")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public User createUser(User us){
    User user =  UserService.createUser(us.getCustomerId(),us.getPassword());
    return user;
}
}

当我点击注册按钮时,除了用于调试的警告框外没有任何其他事情发生。

对于POSTMAN中的此网址:

http://localhost:8081/quickpay/webapi/myresource/createAccount

引发错误:

$(function(){
console.log("Jquery called");
$('#add-account').click(function(event){
    event.preventDefault();
    var firstName = $("#firstName").val();
    var middleName = $("#middleName").val();
    var lastName = $("#lastName").val();
    var gender = $("input:radio[name=gender]").val();
    var address = $("#address").val();
    var pincode = $("#pincode").val();
    var phone = $("#phone").val();
    var email = $("#email").val();
    var password = $("#password").val();
    var balance = $("#balance").val();
    var pin = $("#pin").val();
    var cardId = $("#cardId").val();
    alert("Password:"+password);
    $.ajax({
        type: "POST",
        url: "http://localhost:8081/quickpay/webapi/myresource/createAccount",
        contentType: "application/json; charset=utf-8",
        data: JSON.stringify({
            "balance":balance,
            "pin": pin,
            "cardId": cardId
        }), 
        dataType: "json",
        success:function (successResponse,textStatus,jqXHR) {
            var accountId = successResponse.accountId ;
            $.ajax({
                type: "POST",
                url: "http://localhost:8081/quickpay/webapi/myresource/createCustomer",
                contentType: "application/json; charset=utf-8",
                data: JSON.stringify({
                    "firstName":firstName,
                    "middleName":middleName,
                    "lastName":lastName,
                    "gender":gender,
                    "address":address,
                    "pincode":pincode,
                    "phone":phone,
                    "email":email,
                    "accountId":accountId
                }), 
                dataType: "json",
                success:function (successResponse1,textStatus,jqXHR) {
                    var customerId = successResponse1.customerId;
                    var gender = successResponse1.gender;
                    $.ajax({
                        type: "POST",
                        url: "http://localhost:8081/quickpay/webapi/myresource/createUser",
                        contentType: "application/json; charset=utf-8",
                        data: JSON.stringify({
                            "customerId":customerId,
                            "password":password
                        }), 
                        dataType: "json",
                        success:function (successResponse2,textStatus,jqXHR) {
                            if(textStatus == "success"){
                                alert("Registered:"+textStatus+"\n Use Following credentials to login:\n"
                                        +"Username:"+customerId+"Password:"+password+"\nGender is:"+gender);
                            }
                            else{
                                alert("Status:"+textStatus);
                            }

                            location.reload();
                        },
                        error: function (errorResponse2) {
                            console.log(errorResponse2);
                            alert(errorResponse2);
                        }
                    }); 
                },
                error: function (errorResponse1) {
                    console.log(errorResponse1);
                    alert(errorResponse1);
                }
            }); 
        },
        error: function (errorResponse) {
            console.log(errorResponse);
            alert("Account api");
        }
    });
});
});

在创建Local Git存储库后是否需要执行任何其他步骤。??

更新

我删除了项目并将其作为Maven项目从本地存储库导入。 在我的.project文件中,我发现了一些更改。

<html>
<head>
    <title>Apache Tomcat/7.0.62 - Error report</title>
    <style>
        <!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}-->
    </style>
</head>
<body>
    <h1>HTTP Status 404 - </h1>
    <HR size="1" noshade="noshade">
        <p>
            <b>type</b> Status report
        </p>
        <p>
            <b>message</b>
            <u></u>
        </p>
        <p>
            <b>description</b>
            <u>The requested resource is not available.</u>
        </p>
        <HR size="1" noshade="noshade">
            <h3>Apache Tomcat/7.0.62</h3>
        </body>
    </html>

在这里看一下:

https://github.com/agrawalvikas/quickpay/commit/f38a9a36085c1bb0101fd6b8957924e71373130f

1 个答案:

答案 0 :(得分:0)

删除包浏览器中的项目,然后从主项目的本地存储库所在的目录中再次将其作为Maven项目导入。

我不知道为什么会这样,但它对我有用。 我从这个视频中得到了这样做的参考。

POSIX