मैं निम्नलिखित ट्यूटोरियल के माध्यम से काम कर रहा है @ComponentScanning:IllegalStateException - एक springframework पैकेज
http://spring.io/guides/gs/rest-service/
मैं शुरू में सही ढंग से काम करने के लिए (भागो ट्यूटोरियल समाप्त कोड प्राप्त करने में सक्षम था, एक HTTP संदेश भेजने और सही प्रतिक्रिया प्राप्त करें) और सफलतापूर्वक इसका विस्तार करें।
आगे के विस्तार के बाद, मैं निम्नलिखित अपवाद में भाग:
java.lang.IllegalStateException: Could not evaluate condition on org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration#propertySourcesPlaceholderConfigurer due to internal class not found. This can happen if you are @ComponentScanning a springframework package (e.g. if you put a @ComponentScan in the default package by mistake)
at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:51)
at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:92)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:174)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:136)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:116)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:330)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:243)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:254)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:94)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:611)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:109)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:321)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:961)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:950)
at com.aharrison.hello.Application.main(Application.java:15)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
के बाद वापस केवल क्या उदाहरण में दिखाया गया है करने के लिए नीचे कोड छीन, लेकिन मैं अभी भी अपवाद का सामना कर रहा हूँ मैं है।
https://github.com/spring-projects/spring-boot/issues/2050
मैं बहुत वसंत के साथ अनुभव नहीं कर रहा हूँ, तो मैं पूरी तरह से समझ नहीं सकता क्या है:
मैं बंद कर दिया के रूप में हालांकि यह चिह्नित है लगता है कि यह संभवतः निम्न समस्या से संबंधित हो सकता, विचार - विमर्श किया जा रहा है।
यहाँ मेरे वर्तमान वर्ग हैं:
Greeting.java:
package com.aharrison.hello;
public class Greeting {
private final long id;
private final String content;
public Greeting(long id, String content) {
this.id = id;
this.content = content;
}
public long getId() {
return id;
}
public String getContent() {
return content;
}
}
GreetingController:
package com.aharrison.hello;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.concurrent.atomic.AtomicLong;
@RestController
public class GreetingController {
private static final String template = "Hello, %s!";
private final AtomicLong counter = new AtomicLong();
@RequestMapping("/greeting")
public Greeting greeting(@RequestParam(value="name", defaultValue="World") String name) {
return new Greeting(counter.incrementAndGet(), String.format(template, name));
}
}
Application.java:
package com.aharrison.hello;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
/**
* Created by Adam on 12/26/2014.
*/
@ComponentScan
@EnableAutoConfiguration
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.aharrison</groupId>
<artifactId>SpringRestAPI</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>1.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.1.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>1.6.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>2.12.2</version>
</dependency>
</dependencies>
सवाल:
- क्या इस स्थिति में अपवाद उत्पन्न कर रहा है? क्या ऊपर मेरे कोड के साथ कुछ गड़बड़ है, या समस्या पर्यावरण से संबंधित है?
- जब अपवाद कहता है ".. अगर आप गलती से डिफ़ॉल्ट पैकेज में @ कॉम्पोनेंटस्कैन डालते हैं", तो यह डिफ़ॉल्ट पैकेज है जिसका संदर्भ है? क्या यह वर्तमान स्थिति पर लागू है?
अग्रिम धन्यवाद।
[इस लिंक को चेक करें] (http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#using-boot-build-systems) इस दस्तावेज़ में वसंत को कॉन्फ़िगर करने के तरीके पर स्पष्ट स्पष्टीकरण है मेवेन का उपयोग कर बूट आवेदन। –
स्पष्ट रूप से यह प्रश्न यातायात प्राप्त करता रहता है। मैं ईमानदारी से वर्षों में इस मुद्दे पर जो कुछ भी नेतृत्व कर रहा हूं उस पर काम नहीं कर रहा हूं। मैंने कभी जवाब नहीं स्वीकार किया क्योंकि मुझे कोई समाधान नहीं मिला; अगर मुझे बुरा फॉर्म है तो मुझे बताएं। शुभकामनाएं हर कोई। –