gpt4 book ai didi

java - 无法创建托管 bean,托管 bean heavenMB 的属性不存在

转载 作者:行者123 更新时间:2023-12-01 13:13:55 26 4
gpt4 key购买 nike

我找到了很多关于这个问题的解决方案,但没有人解决我的问题。这是我的托管 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.

有人可以帮忙吗?

最佳答案

看来您打算注入(inject)一个 EJB 而不是其他托管 bean,如果是这样,请像下面这样注入(inject):

@EJB
private DBDataManipulatorService dbDataManipulatorService;

关于java - 无法创建托管 bean,托管 bean heavenMB 的属性不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22611559/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com