Semana 2: Web y API REST con Spring Boot

Semana 2 de Web y API REST con Spring Boot: APIs REST, inyección de dependencias, @Autowired, @RestController y @RequestMapping; pruebas con Postman. Conoce Q2BSTUDIO, software a medida, cloud AWS/Azure, ciberseguridad, IA y BI Power BI.

24 sept 2025 • 2 min read • Q2BSTUDIO Team

Inteligencia-Artificial-

Semana 2: Web y API REST con Spring Boot. Esta semana seguí profundizando en Spring Boot creando APIs REST, entendiendo inyección de dependencias y probando endpoints con Postman para validar comportamiento y depurar errores.

Inyección de dependencias y @Autowired. Exploré la inyección de dependencias en detalle. La inyección por constructor es limpia y funciona sin necesidad de @Autowired cuando hay un solo constructor. La inyección por campos requiere @Autowired para que Spring resuelva e inyecte los beans por tipo, logrando código desacoplado y fácil de probar. Un error que cometí fue instanciar objetos manualmente como en Java puro, lo que rompe el principio IoC. Aprendí a dejar que Spring gestione la creación de objetos. También revisé la configuración en XML para entender cómo se definían beans en proyectos legacy, útil para conceptos fundamentales y entrevistas.

Spring Web y APIs REST. Aprendí a crear controladores REST usando @RestController y @RequestMapping. Descubrí que @RestController combina @Controller y @ResponseBody, por eso no es necesario devolver manualmente el cuerpo de la respuesta. Usé @RequestMapping para mapear rutas como /api/hello y gestionar peticiones. Al usar @Controller sin @ResponseBody obtuve un error de vista, y cambiar a @RestController solucionó el problema. También repasé el flujo del DispatcherServlet: Spring recibe la petición HTTP, la enruta al controlador adecuado y devuelve la respuesta.

Métodos HTTP y práctica con Postman. Reforcé el uso de métodos HTTP en APIs REST: GET para obtener datos y POST para crear recursos. Practiqué enviar JSON y recibir respuestas con Postman, y aprendí a usar @RequestBody para deserializar el cuerpo de las peticiones POST. Un descuido fue olvidar @RequestBody, lo que provocó que los datos no se recibieran correctamente; Postman facilitó la depuración.

Conclusiones de la semana. Comprendí mejor la inyección de dependencias, las diferencias entre constructor y field injection y el uso de @Autowired. Profundicé en configuraciones XML para contexto histórico, construí APIs con @RestController y @RequestMapping, y probé endpoints con Postman identificando errores comunes y cómo solucionarlos.

Sobre Q2BSTUDIO. En Q2BSTUDIO somos una empresa de desarrollo de software especializada en aplicaciones a medida y soluciones tecnológicas avanzadas. Ofrecemos servicios de desarrollo de aplicaciones y software a medida, implantaciones de servicios cloud aws y azure, consultoría en ciberseguridad y pentesting, y soluciones de inteligencia de negocio y power bi. Además contamos con soluciones de inteligencia artificial, agentes IA y servicios de ia para empresas que ayudan a automatizar procesos y mejorar la toma de decisiones. Si buscas una empresa que combine experiencia en backend, APIs REST y tecnologías emergentes como inteligencia artificial y ciberseguridad, en Q2BSTUDIO podemos ayudarte con proyectos a medida.

Palabras clave integradas naturalmente para mejorar posicionamiento: aplicaciones a medida, software a medida, inteligencia artificial, ciberseguridad, servicios cloud aws y azure, servicios inteligencia de negocio, ia para empresas, agentes IA y power bi.

A BREAK?

Play for a moment before you go

OUR SERVICES

How we can help you

Artificial intelligence

AI agents, chatbots, and intelligent assistants that automate tasks and serve your customers 24/7 to improve the efficiency of your business.

More info

Software Development

Web, mobile, and desktop applications, intranets, e-commerce, SaaS, and management platforms designed for your company's specific needs.

More info

Cloud services

Migration, infrastructure, managed hosting, high availability, and security on Microsoft Azure and Amazon Web Services to help your business scale without limits.

More info

Cybersecurity and pentesting

Security audits, penetration testing and protection of applications, data and infrastructure on-premise and cloud, with ethical hacking and regulatory compliance.

More info

Business Intelligence

Dashboards and data analysis with Power BI: we integrate your sources, design dashboards and KPIs and turn your data into decisions.

More info

Process automation

We automate repetitive tasks and connect your applications with n8n, Power Automate, Make, and RPA, eliminating manual work and increasing productivity.

More info

Training for Companies

We train your teams in technology with criteria: web development, databases, Git, best practices and security, automation with n8n, artificial intelligence for companies and creation of AI solutions with Azure AI Foundry.

More info

Code Auditing

We audit the code that you, your team or an AI create: we tell you what is good and what to improve, we secure it and make it ready for production, web or app.

More info

AI Image Generation

We create for you the images that your business needs with artificial intelligence: product, networks, advertising, illustration and avatars. You tell us what you want and we deliver it ready to use.

More info

AI Video Generation

We create videos with artificial intelligence for you: promotional, networking, virtual presenters, dubbing and animations. You tell us the idea and we will deliver it assembled and ready to publish.

More info

AI Conversational Avatars

We create conversational avatars with AI – digital humans with a face and voice – that serve your customers and teams with the knowledge of your company, on your website, interactive monitors, WhatsApp or Teams.

More info

Online Marketing and AI

Google Ads, Meta Ads, LinkedIn Ads and AI Engine Positioning (GEO/AEO): we attract customers and make your brand appear where they search for you, also on ChatGPT, Gemini and Perplexity.

More info

Do you have a project in mind?

Tell us your vision and we'll turn it into a software solution. Whatever the scope, we make your idea real.

Live Chat