我找到了很多有关此问题的解决方案,但没人能解决我的问题。
这是我的托管bean:

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;
import com.bombardier.domain.Aircraft;
import com.bombardier.domain.WorkPackage;
import com.bombardier.services.DBDataManipulatorService;

@ManagedBean(name = "aircraftMB")
@RequestScoped
public class AircraftManagedBean implements Serializable{

private static final long serialVersionUID = 1L;

//Spring User Service is injected...
@ManagedProperty(value="#{DBDataManipulatorServiceImpl}")
DBDataManipulatorService dbDataManipulatorService;

List<Aircraft> aircrafts;

private int aircraftId;
private String type;
private String model;
private Map<String, WorkPackage> workPackagesMap;


public List<Aircraft> getAircrafts() {

    aircrafts = new ArrayList<Aircraft>();
    aircrafts = dbDataManipulatorService.findAllAircrafts();

    return aircrafts;
}

public DBDataManipulatorService getDBDataManipulatorServiceImpl() {

    return dbDataManipulatorService;
}


public void setDBDataManipulatorServiceImpl(DBDataManipulatorService dbDataManipulatorService) {

    this.dbDataManipulatorService = dbDataManipulatorService;

}


public void setAircrafts(List<Aircraft> aircrafts) {
    this.aircrafts = aircrafts;
}

public int getAircraftId() {
    return aircraftId;
}

public void setAircraftId(int aircraftId) {
    this.aircraftId = aircraftId;
}

public String getType() {
    return type;
}

public void setType(String type) {
    this.type = type;
}

public String getModel() {
    return model;
}

public void setModel(String model) {
    this.model = model;
}


public Map<String, WorkPackage> getWorkPackagesMap() {
    return workPackagesMap;
}


public void setWorkPackagesMap(Map<String, WorkPackage> workPackagesMap) {
    this.workPackagesMap = workPackagesMap;
}
}


我的服务如下:

@Service
@Transactional
public class DBDataManipulatorServiceImpl implements DBDataManipulatorService {

@Autowired
private AircraftRepository aircraftRepository;

@Autowired
private WorkPackageRepository workPackageRepository;

@Autowired
private MyJobRepository myJobRepository;

@Override
public Aircraft getAircraftById(String id) {

    return new Aircraft();
}

@Override
@Transactional
public Map<Integer, Aircraft> saveToDataBase(Map<Integer, Aircraft> aircraftsMap) {

    Map<Integer, Aircraft> newaircraftsMap = new HashMap<Integer, Aircraft>();
    Aircraft newAircraft = null;
    for (Aircraft aircraft : aircraftsMap.values()) {
        newAircraft = aircraftRepository.save(aircraft);
        newaircraftsMap.put(newAircraft.getAircraftId(), newAircraft);
    }

    return newaircraftsMap;
}

@Override
@Transactional
public MyJob findJobByJobId(String jobId) {

    MyJob job = myJobRepository.findOne(jobId);
    if (job == null) {

    }

    return job;
}

@Override
@Transactional
public WorkPackage findWorkPackageByAircraftIdAndWorkPackageId(
        int aircraftId, String workPackageId) {

    WorkPackage workPackage = workPackageRepository
            .findWorkPackageByWorkPackageIdAndAircraftId(aircraftId,
                    workPackageId);

    return workPackage;
}

@Override
@Transactional
public Aircraft findAircraftByaircraftId(int aircraftId) {

    return aircraftRepository.findOne(aircraftId);
}

@Override
@Transactional
public List<Aircraft> findAllAircrafts() {

    List<Aircraft> aircrafts;

    aircrafts = aircraftRepository.findAll();

    return aircrafts;

}
}


我收到以下错误:

Unable to create managed bean aircraftMB. The following problems were found: - Property dbDataManipulatorService for managed bean aircraftMB does not exist. Check that appropriate getter and/or setter methods exist.


有人可以帮忙吗?

最佳答案

似乎您打算注入一个EJB而不是其他托管bean,如果是这样,则按如下所示注入它:

@EJB
private DBDataManipulatorService dbDataManipulatorService;

09-26 06:50