我一直得到这个错误,并且无法弄清楚为什么......是的我知道很多人都有类似的问题,但是阅读他们得到的答案并不能解决我的问题.
org.springframework.beans.factory.BeanCreationException:创建名为'contactController'的bean时出错:注入自动连接的依赖项失败; 嵌套异常是org.springframework.beans.factory.BeanCreationException:无法自动装配字段:private net.service.ContactService net.controller.ContactController.contactService; 嵌套异常是org.springframework.beans.factory.NoSuchBeanDefinitionException:没有找到类型为[net.service.ContactService]的匹配bean用于依赖:预期至少有一个bean有资格作为此依赖项的autowire候选者.依赖注释:{@ org.springframework.beans.factory.annotation.Autowired(required = true)}
这是控制器:
@Controller
@SessionAttributes
public class ContactController {
@Autowired
private ContactService contactService;
//methods...
}
Run Code Online (Sandbox Code Playgroud)
ContactServiceImpl
@Service("contactService")
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public class ContactServiceImpl implements ContactService {
@Autowired
private ContactDao contactDao;
public ContactServiceImpl() {
}
@Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public void addContact(Contact contact) {
contactDao.saveContact(contact);
}
@Override
public List<Contact> getContacts() {
return contactDao.getAllContacts();
}
}
Run Code Online (Sandbox Code Playgroud)
ContactDaoImpl
@Repository("contactDao")
public class ContactDaoImpl implements ContactDao {
@Autowired
private SessionFactory sessionFactory;
@Override …
Run Code Online (Sandbox Code Playgroud) 更新:这是我的maven-compiler-plugin配置:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
Run Code Online (Sandbox Code Playgroud)
我在使用Maven构建的多项目应用程序上工作.我们决定添加AspectJ,所以我pom.xml
在顶级项目中添加了以下代码:(来自官方文档)
<project>
...
<dependencies>
...
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.7.3</version>
</dependency>
...
</dependencies>
...
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<goals>
<goal>compile</goal> <!-- use this goal to weave all your main classes -->
<goal>test-compile</goal> <!-- use this goal to weave all your test classes -->
</goals>
</execution>
</executions>
</plugin>
...
</plugins>
<build>
...
</project>
Run Code Online (Sandbox Code Playgroud)
以及每个下属项目的以下片段:
</project>
...
<build>
....
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
</plugin>
</plugins>
</build> …
Run Code Online (Sandbox Code Playgroud) 首选项 - > Java - >编辑器 - >保存操作选中"在保存时执行选定的操作",然后选中"其他操作"并单击"配置.."按钮.在"代码组织"选项卡中,选中"删除尾随空格"
这将完成任何普通代码的工作,但这不会对评论产生任何影响.有没有办法自动摆脱评论行的尾随空格?
谢谢,
p
我想使用Spring MVC和Hibernate在PostgresQL中存储一个实体(一个String +一个图像)这是我的表.该图像应该是oid的类型.
CREATE TABLE document
(
name character varying(200),
id serial NOT NULL,
content oid, // that should be the image
CONSTRAINT document_pkey PRIMARY KEY (id )
)
WITH (
OIDS=FALSE
);
Run Code Online (Sandbox Code Playgroud)
这是我想要存储的实体.
@Entity
@Table(name = "document")
public class Document {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
@Column(name = "name")
private String name;
@Column(name="content")
private Blob content; //this is the image
//getters- setters
Run Code Online (Sandbox Code Playgroud)
您可以看到变量"name"是String,而不是Long.仍然当我提交一个不是数字的值的表单时,它会抛出 org.postgresql.util.PSQLException: Bad value for type long : x
这是表格:
<form:form method="post" …
Run Code Online (Sandbox Code Playgroud) 我尝试执行以下命令(Postgresql):
ALTER TABLE authentication ADD CONSTRAINT overlapping_times EXCLUDE USING GIST
(method with =,
authenticator with =,
box(point(extract(epoch FROM validfrom at time zone 'UTC'),extract(epoch FROM validfrom at time zone 'UTC') ),
point(extract(epoch FROM validuntil at time zone 'UTC'), extract(epoch FROM validuntil at time zone 'UTC'))) WITH &&
)
Run Code Online (Sandbox Code Playgroud)
我收到以下错误消息:
ERROR: data type character varying has no default operator class for access method "gist"
HINT: You must specify an operator class for the index or define a default operator class for the …
Run Code Online (Sandbox Code Playgroud) 如何配置AspectJ以获得编译后的编织?我只是在下面的插件中将“ compile”替换为“ post-compile” :(不必说这是不成功的)
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.5</version>
<configuration>
<complianceLevel>1.6</complianceLevel>
<source>1.6</source>
<target>1.6</target>
</configuration>
<executions>
<execution>
<goals>
<goal>post-compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
但我错过了一些东西,因为它给出了以下错误:
'post-compile' was specified in an execution, but not found in the plugin
Run Code Online (Sandbox Code Playgroud) 我使用vaadin 7并使用maven构建它.
有一个名为'the_name_of_myProject'/ src/main/webapp/VAADIN/themes/mytheme/styles.css的CSS文件如果我以任何方式修改它,我的修改将被下一个maven构建覆盖.看起来总是从jar重新生成文件.
如果我希望这些修改能够存活,我该怎么办?
我用不同的名称创建了自己的主题,但它也没有帮助,因为它的.css以相同的方式被覆盖.
任何建议表示赞赏.
我想servlet
从命令提示符编译一个非常基本的,但它总是不成功,编译器告诉我以下内容:
error: package javax.servlet does not exist.
Run Code Online (Sandbox Code Playgroud)
我搜索了解决方案,我发现我需要将servlet.jar
库包含到我的PATH中.我相信我做到了.我坚信我的计算机中这些库的位置是:
C:\apache-tomcat-7.0.23\lib\servlet-api.jar\
Run Code Online (Sandbox Code Playgroud)
我的PATH的结尾(相关部分)如下:
%JAVA_HOME%\bin;C:\apache-tomcat-7.0.23\lib\servlet-api.jar\
Run Code Online (Sandbox Code Playgroud)
对我来说,它看起来不错,但显然不是.谁能告诉我可能是什么问题?
我想使用Spring MVC 3,Hibernate和PostgresQL注册用户.这是我想提交的表格:
<form:form name="registerForm" method="post"
action="registerNewUser.html" commandName="user">
<table>
<tr>
<td><spring:message code="label.userName" /></td>
<td><form:input path="userName" /></td>
<td><form:errors path="userName" cssClass="error" /></td>
</tr>
<tr>
<td><spring:message code="label.password" /></td>
<td><form:password path="password" /></td>
<td><form:errors path="password" cssClass="error" /></td>
</tr>
<tr>
<td><spring:message code="label.password" /></td>
<td><form:password path="retypePassword" /></td>
<td><form:errors path="retypePassword" cssClass="error" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit"
value="<spring:message code="register.label" />" /></td>
</tr>
</table>
</form:form>
Run Code Online (Sandbox Code Playgroud)
这是我要保存的POJO:
@Entity
@Table(name = "user_table")
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
@Column(name = "user_name", nullable = …
Run Code Online (Sandbox Code Playgroud) 这是我非常简单的表格(Postgres):
CREATE TABLE IF NOT EXISTS PERFORMANCE.TEST
(
test text NOT NULL UNIQUE
);
Run Code Online (Sandbox Code Playgroud)
如果我尝试使用下面的命令从数据库插入一个字符串,一切都按预期工作,毫不奇怪,数据库中出现一个新行.
insert into performance.test (test) values ('abbbbaw');
Run Code Online (Sandbox Code Playgroud)
但是,如果我想通过JDBC插入String,则不会插入任何内容,尽管preparedStatement.executeUpdate()始终返回1.
下面是我应该工作的方法,但事实并非如此.请告诉我,如果我遗漏了一些明显的东西.我想补充一点,我从来没有得到任何SQLException.
private void storePerformance() {
Connection conn= initializePerformanceConnection();
if (conn!= null) {
PreparedStatement insertPS = null;
try {
insertPS = conn.prepareStatement("insert into performance.test (test) values (?)");
insertPS.setString(1, queryVar);
int i = insertPS.executeUpdate();
LogManager.doLog(LOG, LOGLEVEL.INFO," numberofrows= "+i);
} catch (SQLException e) {
LogManager.doLog(LOG, LOGLEVEL.INFO,"Inserting query failed = "+queryVar,e);
}finally{
if(insertPS != null){
try {
insertPS.close();
} catch (SQLException e) …
Run Code Online (Sandbox Code Playgroud)